diff --git a/.gitignore b/.gitignore index 2480b83823..1fc3016d3f 100644 --- a/.gitignore +++ b/.gitignore @@ -11,10 +11,6 @@ .deps .\#* \#* -/Debug/ -/Release/ -/All/ -/bin/ *.user *.suo *.ncb @@ -39,105 +35,115 @@ *.xz *.bz2 *.tbz2 +aclocal.m4 +autom4te.cache +config.cache +configure.lineno +config.log +config.status core.* -/Path + /w32/Library/lastversion /w32/Library/tmpVersion.Bat !/w32/Console/FreeSwitchConsole.vcproj.user !/w32/Setup/inno_setup/vcredist_x64.exe !/w32/Setup/inno_setup/vcredist_x86.exe -.version -AUTHORS -COPYING -ChangeLog -Makefile -Makefile.in -NEWS -README -TAGS -aclocal.m4 -autom4te.cache -build/Makefile -build/Makefile.in -build/config/compile -build/config/config.guess -build/config/depcomp -build/config/install-sh -build/config/ltmain.sh -build/config/missing -build/freeswitch.pc -build/getlib.sh -build/getsounds.sh -build/modmake.rules -build/getg729.sh -config.cache -config.log -config.status -configure -configure.lineno -freeswitch -fs_cli -fs_encode -fs_ivrd -libtool -noreg -modules.conf -quiet_libtool -tone2wav -scripts/fsxs -scripts/gentls_cert -a.out.dSYM -src/mod/applications/mod_easyroute/Makefile -src/mod/applications/mod_lcr/Makefile -src/mod/applications/mod_nibblebill/Makefile -src/mod/applications/mod_rss/Makefile -src/mod/applications/mod_snipe_hunt/Makefile -src/mod/codecs/mod_dahdi_codec/Makefile -src/mod/dialplans/mod_dialplan_directory/Makefile -src/mod/formats/mod_shell_stream/Makefile -src/mod/say/mod_say_de/Makefile -src/mod/say/mod_say_es/Makefile -src/mod/say/mod_say_fr/Makefile -src/mod/say/mod_say_it/Makefile -src/mod/say/mod_say_nl/Makefile -src/mod/say/mod_say_th/Makefile -src/mod/say/mod_say_zh/Makefile -libs/curl/lib/ca-bundle.h -libs/g729/ -libs/fsg729-*-installer -src/mod/codecs/mod_com_g729/ -src/mod/languages/mod_lua/mod_lua_wrap.cpp.orig -src/mod/languages/mod_perl/mod_perl_wrap.cpp.orig -src/mod/languages/mod_python/mod_python_wrap.cpp.orig -libs/freetdm/detect_dtmf -libs/freetdm/detect_tones -libs/freetdm/testanalog -libs/freetdm/testapp -libs/freetdm/testcid -libs/freetdm/testpri -libs/freetdm/testr2 -libs/freetdm/testsangomaboost -libs/freetdm/testtones -libs/esl/fs_cli -libs/esl/ivrd -libs/esl/testserver -libs/esl/testclient -libs/libcodec2/Makefile -libs/libcodec2/Makefile.in -libs/libcodec2/config.guess -libs/libcodec2/config.sub -libs/libcodec2/configure -libs/libcodec2/depcomp -libs/libcodec2/install-sh -libs/libcodec2/libtool -libs/libcodec2/ltmain.sh -libs/libcodec2/missing -libs/libcodec2/src/Makefile -libs/libcodec2/src/Makefile.in -libs/libcodec2/unittest/Makefile -libs/libcodec2/unittest/Makefile.in -src/mod/applications/mod_osp/Makefile -src/mod/applications/mod_osp/Makefile.in -src/mod/applications/mod_hash/Makefile -src/mod/applications/mod_hash/Makefile.in -src/mod/applications/mod_hash/mod_hash.log + +/.version +/a.out.dSYM +/AUTHORS +/ChangeLog +/configure +/COPYING +/freeswitch +/fs_cli +/fs_encode +/fs_ivrd +/libtool +/Makefile +/Makefile.in +/modules.conf +/NEWS +/Path +/quiet_libtool +/README +/TAGS +/tone2wav + +/All/ +/Debug/ +/bin/ +/Release/ + +/build/config/compile +/build/config/config.guess +/build/config/depcomp +/build/config/install-sh +/build/config/ltmain.sh +/build/config/missing +/build/freeswitch.pc +/build/getlib.sh +/build/getsounds.sh +/build/Makefile +/build/Makefile.in +/build/modmake.rules + +/libs/curl/lib/ca-bundle.h +/libs/esl/fs_cli +/libs/esl/ivrd +/libs/esl/testclient +/libs/esl/testserver +/libs/freetdm/detect_dtmf +/libs/freetdm/detect_tones +/libs/freetdm/testanalog +/libs/freetdm/testapp +/libs/freetdm/testcid +/libs/freetdm/testpri +/libs/freetdm/testr2 +/libs/freetdm/testsangomaboost +/libs/freetdm/testtones +/libs/fsg729-*-installer +/libs/g729/ +/libs/libcodec2/config.guess +/libs/libcodec2/config.sub +/libs/libcodec2/configure +/libs/libcodec2/depcomp +/libs/libcodec2/install-sh +/libs/libcodec2/libtool +/libs/libcodec2/ltmain.sh +/libs/libcodec2/Makefile +/libs/libcodec2/Makefile.in +/libs/libcodec2/missing +/libs/libcodec2/src/Makefile +/libs/libcodec2/src/Makefile.in +/libs/libcodec2/unittest/Makefile +/libs/libcodec2/unittest/Makefile.in + +/scripts/fsxs +/scripts/gentls_cert + +/src/mod/applications/mod_easyroute/Makefile +/src/mod/applications/mod_hash/Makefile +/src/mod/applications/mod_hash/Makefile.in +/src/mod/applications/mod_hash/mod_hash.log +/src/mod/applications/mod_lcr/Makefile +/src/mod/applications/mod_nibblebill/Makefile +/src/mod/applications/mod_osp/Makefile +/src/mod/applications/mod_osp/Makefile.in +/src/mod/applications/mod_rss/Makefile +/src/mod/applications/mod_snipe_hunt/Makefile +/src/mod/codecs/mod_com_g729/ +/src/mod/codecs/mod_dahdi_codec/Makefile +/src/mod/dialplans/mod_dialplan_directory/Makefile +/src/mod/formats/mod_shell_stream/Makefile +/src/mod/languages/mod_lua/mod_lua_wrap.cpp.orig +/src/mod/languages/mod_perl/mod_perl_wrap.cpp.orig +/src/mod/languages/mod_python/mod_python_wrap.cpp.orig +/src/mod/say/mod_say_de/Makefile +/src/mod/say/mod_say_es/Makefile +/src/mod/say/mod_say_fr/Makefile +/src/mod/say/mod_say_it/Makefile +/src/mod/say/mod_say_nl/Makefile +/src/mod/say/mod_say_th/Makefile +/src/mod/say/mod_say_zh/Makefile + diff --git a/Makefile.am b/Makefile.am index 37a01d27fb..5b6b9896ac 100644 --- a/Makefile.am +++ b/Makefile.am @@ -356,7 +356,7 @@ scripts/fsxs: scripts/fsxs.in ## misc ## -pkgconfigdir = $(libdir)/pkgconfig +pkgconfigdir = @pkgconfigdir@ pkgconfig_DATA = build/freeswitch.pc $(switch_builddir)/modules.conf: diff --git a/build/getlib.sh.in b/build/getlib.sh.in index ebad7b5084..f328b87d45 100755 --- a/build/getlib.sh.in +++ b/build/getlib.sh.in @@ -1,5 +1,8 @@ #!/bin/sh +bz="false" + +BUNZIP=/usr/bin/bunzip2 TAR=@TAR@ ZCAT=@ZCAT@ WGET=@WGET@ @@ -17,14 +20,26 @@ base=http://files.freeswitch.org/downloads/libs/ tarfile=$1 url=`echo $tarfile | grep "://"` +if [ `echo $tarfile | grep bz2` ] ; then + bz="true" + UNZIPPER=$BUNZIP +else + UNZIPPER=$ZCAT +fi + if [ ! -z $url ] ; then base=$tarfile/ tarfile=$2 fi if [ ! -d $tarfile ] ; then - uncompressed=`echo $tarfile | sed "s/\.tar\.gz//g"` - uncompressed=`echo $uncompressed | sed "s/\.tgz//g"` + + if [ $bz = "true" ] ; then + uncompressed=`echo $tarfile | sed "s/\.tar\.bz2//g"` + else + uncompressed=`echo $tarfile | sed "s/\.tar\.gz//g"` + uncompressed=`echo $uncompressed | sed "s/\.tgz//g"` + fi if [ ! -f $tarfile ] ; then rm -fr $uncompressed @@ -35,7 +50,7 @@ if [ ! -d $tarfile ] ; then fi fi if [ ! -d $uncompressed ] ; then - $ZCAT -c -d $tarfile | $TAR xf - + $UNZIPPER -c -d $tarfile | $TAR xf - fi fi diff --git a/conf/autoload_configs/conference.conf.xml b/conf/autoload_configs/conference.conf.xml index cab0578a57..d4e5aa60ee 100644 --- a/conf/autoload_configs/conference.conf.xml +++ b/conf/autoload_configs/conference.conf.xml @@ -52,8 +52,9 @@ - - + + + @@ -106,7 +107,7 @@ - + @@ -131,7 +132,7 @@ - + @@ -156,7 +157,7 @@ - + diff --git a/conf/autoload_configs/switch.conf.xml b/conf/autoload_configs/switch.conf.xml index 4f72c6a65d..d2500a6463 100644 --- a/conf/autoload_configs/switch.conf.xml +++ b/conf/autoload_configs/switch.conf.xml @@ -24,6 +24,11 @@ + + + + + diff --git a/conf/skinny_profiles/internal.xml b/conf/skinny_profiles/internal.xml index 52da89741d..0ca4ed0c46 100644 --- a/conf/skinny_profiles/internal.xml +++ b/conf/skinny_profiles/internal.xml @@ -16,12 +16,16 @@ - - - + + + + + + + diff --git a/conf/vars.xml b/conf/vars.xml index 0e8782cff0..94529aa9bc 100644 --- a/conf/vars.xml +++ b/conf/vars.xml @@ -207,6 +207,7 @@ + + + + diff --git a/libs/freetdm/configure.ac b/libs/freetdm/configure.ac index 38f849b9e6..55185cb10d 100644 --- a/libs/freetdm/configure.ac +++ b/libs/freetdm/configure.ac @@ -65,6 +65,18 @@ AC_ARG_WITH([modinstdir], ) AC_SUBST([modinstdir]) +# freetdm.pc pkgconfig file +AC_ARG_WITH([pkgconfigdir], + [AS_HELP_STRING([--with-pkgconfigdir=DIR], [Installation directory for pkgconfig file (default: ${libdir}/pkgconfig)])], + [case "${withval}" in + yes|no) AC_MSG_ERROR([Invalid value ${withval} for option --with-pkgconfigdir]) ;; + *) pkgconfigdir="${withval}" ;; + esac + ], + [pkgconfigdir="${libdir}/pkgconfig"] +) +AC_SUBST([pkgconfigdir]) + AC_ARG_ENABLE([enable_64], [AS_HELP_STRING([--enable-64], [Enable 64bit compilation])], [enable_64="${enableval}"], diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.c b/libs/freetdm/mod_freetdm/mod_freetdm.c index 4c8c12432a..0652a8e128 100755 --- a/libs/freetdm/mod_freetdm/mod_freetdm.c +++ b/libs/freetdm/mod_freetdm/mod_freetdm.c @@ -2780,6 +2780,7 @@ static switch_status_t load_config(void) const char *hangup_polarity = "false"; int polarity_delay = 600; int callwaiting = 1; + int dialtone_timeout = 5000; uint32_t span_id = 0, to = 0, max = 0; ftdm_span_t *span = NULL; @@ -2820,6 +2821,8 @@ static switch_status_t load_config(void) tonegroup = val; } else if (!strcasecmp(var, "digit_timeout") || !strcasecmp(var, "digit-timeout")) { digit_timeout = val; + } else if (!strcasecmp(var, "wait-dialtone-timeout")) { + dialtone_timeout = atoi(val); } else if (!strcasecmp(var, "context")) { context = val; } else if (!strcasecmp(var, "dialplan")) { @@ -2920,6 +2923,7 @@ static switch_status_t load_config(void) "hangup_polarity_reverse", hangup_polarity, "polarity_delay", &polarity_delay, "callwaiting", &callwaiting, + "wait_dialtone_timeout", &dialtone_timeout, FTDM_TAG_END) != FTDM_SUCCESS) { ftdm_log(FTDM_LOG_ERROR, "Error configuring FreeTDM analog span %s\n", ftdm_span_get_name(span)); continue; diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c index ade6a7525f..1951678d73 100644 --- a/libs/freetdm/src/ftdm_io.c +++ b/libs/freetdm/src/ftdm_io.c @@ -2335,7 +2335,7 @@ FT_DECLARE(ftdm_status_t) _ftdm_channel_call_indicate(const char *file, const ch break; case FTDM_CHANNEL_INDICATE_PROCEED: if (!ftdm_test_flag(ftdmchan->span, FTDM_SPAN_USE_PROCEED_STATE) || - ftdmchan->state == FTDM_CHANNEL_STATE_PROCEED) { + ftdmchan->state >= FTDM_CHANNEL_STATE_PROCEED) { ftdm_ack_indication(ftdmchan, indication, status); goto done; } @@ -2411,11 +2411,6 @@ static ftdm_status_t _ftdm_channel_call_place_nl(const char *file, const char *f goto done; } - if (ftdmchan->state != FTDM_CHANNEL_STATE_DOWN) { - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Cannot place call in channel in state %s!\n", ftdm_channel_state2str(ftdmchan->state)); - goto done; - } - status = ftdmchan->span->outgoing_call(ftdmchan); if (status == FTDM_BREAK) { /* the signaling module detected glare on time */ @@ -5542,17 +5537,30 @@ FT_DECLARE(ftdm_status_t) ftdm_global_init(void) ftdm_mutex_create(&globals.call_id_mutex); ftdm_sched_global_init(); + globals.running = 1; if (ftdm_sched_create(&globals.timingsched, "freetdm-master") != FTDM_SUCCESS) { ftdm_log(FTDM_LOG_CRIT, "Failed to create master timing schedule context\n"); - return FTDM_FAIL; + goto global_init_fail; } if (ftdm_sched_free_run(globals.timingsched) != FTDM_SUCCESS) { ftdm_log(FTDM_LOG_CRIT, "Failed to run master timing schedule context\n"); - return FTDM_FAIL; + goto global_init_fail; } - - globals.running = 1; + return FTDM_SUCCESS; + +global_init_fail: + globals.running = 0; + ftdm_mutex_destroy(&globals.mutex); + ftdm_mutex_destroy(&globals.span_mutex); + ftdm_mutex_destroy(&globals.group_mutex); + ftdm_mutex_destroy(&globals.call_id_mutex); + hashtable_destroy(globals.interface_hash); + hashtable_destroy(globals.module_hash); + hashtable_destroy(globals.span_hash); + hashtable_destroy(globals.group_hash); + + return FTDM_FAIL; } FT_DECLARE(ftdm_status_t) ftdm_global_configuration(void) diff --git a/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.c b/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.c index 818f1c5754..d25d38f3d7 100644 --- a/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.c +++ b/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.c @@ -182,7 +182,7 @@ static FIO_SIG_CONFIGURE_FUNCTION(ftdm_analog_configure_span) const char *tonemap = "us"; const char *hotline = ""; uint32_t digit_timeout = 10; - uint32_t wait_dialtone_timeout = 30000; + uint32_t wait_dialtone_timeout = 5000; uint32_t max_dialstr = MAX_DTMF; uint32_t polarity_delay = 600; const char *var, *val; diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c index 9cac9d05b1..a9d2d06c32 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c @@ -649,7 +649,7 @@ void sngisdn_process_rel_ind (sngisdn_event_data_t *sngisdn_event) break; case FTDM_CHANNEL_STATE_TERMINATING: if (sngisdn_test_flag(sngisdn_info, FLAG_GLARE) && - sngisdn_info->glare.suInstId != suInstId) { + sngisdn_info->glare.suInstId != suInstId) { /* This release if for the outbound call that we already started clearing */ ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Received RELEASE for local glared call\n"); @@ -667,7 +667,6 @@ void sngisdn_process_rel_ind (sngisdn_event_data_t *sngisdn_event) default: ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "Received RELEASE in an invalid state (%s)\n", ftdm_channel_state2str(ftdmchan->state)); - break; } diff --git a/libs/stfu/stfu.c b/libs/stfu/stfu.c index d2c443a9e7..f00dfafa39 100644 --- a/libs/stfu/stfu.c +++ b/libs/stfu/stfu.c @@ -102,7 +102,10 @@ struct stfu_instance { int32_t ts_offset; int32_t ts_drift; - + int32_t max_drift; + uint32_t drift_dropped_packets; + uint32_t drift_max_dropped; + int32_t ts_diff; int32_t last_ts_diff; int32_t same_ts; @@ -258,7 +261,7 @@ stfu_status_t stfu_n_resize(stfu_instance_t *i, uint32_t qlen) return s; } -stfu_instance_t *stfu_n_init(uint32_t qlen, uint32_t max_qlen, uint32_t samples_per_packet, uint32_t samples_per_second) +stfu_instance_t *stfu_n_init(uint32_t qlen, uint32_t max_qlen, uint32_t samples_per_packet, uint32_t samples_per_second, uint32_t max_drift_ms) { struct stfu_instance *i; @@ -277,6 +280,12 @@ stfu_instance_t *stfu_n_init(uint32_t qlen, uint32_t max_qlen, uint32_t samples_ stfu_n_init_aqueue(&i->b_queue, qlen); stfu_n_init_aqueue(&i->c_queue, qlen); + i->max_drift = (int32_t)(max_drift_ms * (samples_per_second / 1000) * -1); + + if (max_drift_ms && samples_per_packet) { + i->drift_max_dropped = (samples_per_second * 2) / samples_per_packet; + } + i->in_queue = &i->a_queue; i->out_queue = &i->b_queue; i->old_queue = &i->c_queue; @@ -396,6 +405,9 @@ stfu_status_t stfu_n_add_data(stfu_instance_t *i, uint32_t ts, uint32_t pt, void if (i->last_ts_diff == i->ts_diff) { if (++i->same_ts == 5) { i->samples_per_packet = i->ts_diff; + if (i->max_drift && i->samples_per_packet) { + i->drift_max_dropped = (i->samples_per_second * 2) / i->samples_per_packet; + } } } else { i->same_ts = 0; @@ -409,11 +421,24 @@ stfu_status_t stfu_n_add_data(stfu_instance_t *i, uint32_t ts, uint32_t pt, void } } - if (timer_ts && ts && !i->ts_offset) { - i->ts_offset = timer_ts - ts; - } + if (timer_ts) { + if (ts && !i->ts_offset) { + i->ts_offset = timer_ts - ts; + } - i->ts_drift = ts + (i->ts_offset - timer_ts); + i->ts_drift = ts + (i->ts_offset - timer_ts); + + if (i->max_drift) { + if (i->ts_drift < i->max_drift) { + if (++i->drift_dropped_packets < i->drift_max_dropped) { + stfu_log(STFU_LOG_EMERG, "%s TOO LATE !!! %u \n\n\n", i->name, ts); + return STFU_ITS_TOO_LATE; + } + } else { + i->drift_dropped_packets = 0; + } + } + } if (i->sync_in) { good_ts = 1; @@ -493,12 +518,12 @@ stfu_status_t stfu_n_add_data(stfu_instance_t *i, uint32_t ts, uint32_t pt, void if (stfu_log != null_logger && i->debug) { - stfu_log(STFU_LOG_EMERG, "I: %s %u i=%u/%u - g:%u/%u c:%u/%u b:%u - %u:%u - %u %d %u %u %d %d %d\n", i->name, + stfu_log(STFU_LOG_EMERG, "I: %s %u i=%u/%u - g:%u/%u c:%u/%u b:%u - %u:%u - %u %d %u %u %d %d %d/%d\n", i->name, i->qlen, i->period_packet_in_count, i->period_time, i->consecutive_good_count, i->decrement_time, i->period_clean_count, i->decrement_time, i->consecutive_bad_count, ts, ts / i->samples_per_packet, i->period_missing_count, i->period_need_range_avg, - i->last_wr_ts, ts, i->diff, i->diff_total / least1(i->period_packet_in_count), i->ts_drift); + i->last_wr_ts, ts, i->diff, i->diff_total / least1(i->period_packet_in_count), i->ts_drift, i->max_drift); } if (last || i->in_queue->array_len == i->in_queue->array_size) { @@ -597,7 +622,7 @@ stfu_frame_t *stfu_n_read_a_frame(stfu_instance_t *i) if (!i->ready) { if (stfu_log != null_logger && i->debug) { - stfu_log(STFU_LOG_EMERG, "%s XXXSKIP\n", i->name); + stfu_log(STFU_LOG_EMERG, "%s JITTERBUFFER NOT READY: IGNORING FRAME\n", i->name); } return NULL; } @@ -612,7 +637,7 @@ stfu_frame_t *stfu_n_read_a_frame(stfu_instance_t *i) } if (i->cur_ts == 0) { if (stfu_log != null_logger && i->debug) { - stfu_log(STFU_LOG_EMERG, "%s XXXPUNT\n", i->name); + stfu_log(STFU_LOG_EMERG, "%s JITTERBUFFER ERROR: PUNTING\n", i->name); return NULL; } } diff --git a/libs/stfu/stfu.h b/libs/stfu/stfu.h index b92bb3f839..d8fbf447af 100644 --- a/libs/stfu/stfu.h +++ b/libs/stfu/stfu.h @@ -179,7 +179,7 @@ typedef void (*stfu_n_call_me_t)(stfu_instance_t *i, void *); void stfu_n_report(stfu_instance_t *i, stfu_report_t *r); void stfu_n_destroy(stfu_instance_t **i); -stfu_instance_t *stfu_n_init(uint32_t qlen, uint32_t max_qlen, uint32_t samples_per_packet, uint32_t samples_per_second); +stfu_instance_t *stfu_n_init(uint32_t qlen, uint32_t max_qlen, uint32_t samples_per_packet, uint32_t samples_per_second, uint32_t max_drift_ms); stfu_status_t stfu_n_resize(stfu_instance_t *i, uint32_t qlen); stfu_status_t stfu_n_add_data(stfu_instance_t *i, uint32_t ts, uint32_t pt, void *data, size_t datalen, uint32_t timer_ts, int last); stfu_frame_t *stfu_n_read_a_frame(stfu_instance_t *i); diff --git a/src/include/private/switch_core_pvt.h b/src/include/private/switch_core_pvt.h index ab0777ed3b..0ef64d1079 100644 --- a/src/include/private/switch_core_pvt.h +++ b/src/include/private/switch_core_pvt.h @@ -249,6 +249,8 @@ struct switch_runtime { switch_dbtype_t odbc_dbtype; char hostname[256]; int multiple_registrations; + uint32_t max_db_handles; + uint32_t db_handle_timeout; }; extern struct switch_runtime runtime; diff --git a/src/include/switch_channel.h b/src/include/switch_channel.h index c0bef4be59..25273bafc4 100644 --- a/src/include/switch_channel.h +++ b/src/include/switch_channel.h @@ -79,6 +79,7 @@ SWITCH_DECLARE(int) switch_channel_test_ready(switch_channel_t *channel, switch_ #define switch_channel_ready(_channel) switch_channel_test_ready(_channel, SWITCH_TRUE, SWITCH_FALSE) #define switch_channel_media_ready(_channel) switch_channel_test_ready(_channel, SWITCH_TRUE, SWITCH_TRUE) +#define switch_channel_media_up(_channel) (switch_channel_test_flag(_channel, CF_ANSWERED) || switch_channel_test_flag(_channel, CF_EARLY_MEDIA)) #define switch_channel_up(_channel) (switch_channel_get_state(_channel) < CS_HANGUP) #define switch_channel_down(_channel) (switch_channel_get_state(_channel) >= CS_HANGUP) diff --git a/src/include/switch_core.h b/src/include/switch_core.h index 984b54fac7..590e01ace2 100644 --- a/src/include/switch_core.h +++ b/src/include/switch_core.h @@ -2075,52 +2075,40 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_preprocess_session(switch_core_sessio */ #define CACHE_DB_LEN 256 - typedef enum { - CDF_INUSE = (1 << 0), - CDF_PRUNE = (1 << 1) - } cache_db_flag_t; +typedef enum { + CDF_INUSE = (1 << 0), + CDF_PRUNE = (1 << 1) +} cache_db_flag_t; - typedef enum { - SCDB_TYPE_CORE_DB, - SCDB_TYPE_ODBC - } switch_cache_db_handle_type_t; +typedef enum { + SCDB_TYPE_CORE_DB, + SCDB_TYPE_ODBC +} switch_cache_db_handle_type_t; - typedef union { - switch_core_db_t *core_db_dbh; - switch_odbc_handle_t *odbc_dbh; - } switch_cache_db_native_handle_t; +typedef union { + switch_core_db_t *core_db_dbh; + switch_odbc_handle_t *odbc_dbh; +} switch_cache_db_native_handle_t; - typedef struct { - char *db_path; - } switch_cache_db_core_db_options_t; +typedef struct { + char *db_path; +} switch_cache_db_core_db_options_t; - typedef struct { - char *dsn; - char *user; - char *pass; - } switch_cache_db_odbc_options_t; +typedef struct { + char *dsn; + char *user; + char *pass; +} switch_cache_db_odbc_options_t; - typedef union { - switch_cache_db_core_db_options_t core_db_options; - switch_cache_db_odbc_options_t odbc_options; - } switch_cache_db_connection_options_t; +typedef union { + switch_cache_db_core_db_options_t core_db_options; + switch_cache_db_odbc_options_t odbc_options; +} switch_cache_db_connection_options_t; - typedef struct { - char name[CACHE_DB_LEN]; - switch_cache_db_handle_type_t type; - switch_cache_db_native_handle_t native_handle; - time_t last_used; - switch_mutex_t *mutex; - switch_mutex_t *io_mutex; - switch_memory_pool_t *pool; - int32_t flags; - unsigned long hash; - char creator[CACHE_DB_LEN]; - char last_user[CACHE_DB_LEN]; - } switch_cache_db_handle_t; +struct switch_cache_db_handle; +typedef struct switch_cache_db_handle switch_cache_db_handle_t; - - static inline const char *switch_cache_db_type_name(switch_cache_db_handle_type_t type) +static inline const char *switch_cache_db_type_name(switch_cache_db_handle_type_t type) { const char *type_str = "INVALID"; @@ -2140,6 +2128,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_preprocess_session(switch_core_sessio return type_str; } +SWITCH_DECLARE(switch_cache_db_handle_type_t) switch_cache_db_get_type(switch_cache_db_handle_t *dbh); + /*! \brief Returns the handle to the pool, immediately available for other threads to use. @@ -2152,11 +2142,6 @@ SWITCH_DECLARE(void) switch_cache_db_dismiss_db_handle(switch_cache_db_handle_t \param [in] The handle */ SWITCH_DECLARE(void) switch_cache_db_release_db_handle(switch_cache_db_handle_t ** dbh); -/*! - \brief Removes the handle from the pool and frees up the handle resources. - \param [in] The handle -*/ -SWITCH_DECLARE(void) switch_cache_db_destroy_db_handle(switch_cache_db_handle_t ** dbh); /*! \brief Gets a new cached handle from the pool, potentially creating a new connection. The connection is bound to the thread until it (the thread) terminates unless @@ -2217,19 +2202,40 @@ SWITCH_DECLARE(switch_bool_t) switch_cache_db_test_reactive(switch_cache_db_hand const char *test_sql, const char *drop_sql, const char *reactive_sql); SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute(switch_cache_db_handle_t *dbh, const char *sql, uint32_t retries); SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute_trans(switch_cache_db_handle_t *dbh, char *sql, uint32_t retries); -/*! - \brief Tries to detach all free connections from current thread. -*/ -SWITCH_DECLARE(void) switch_cache_db_detach(void); + SWITCH_DECLARE(uint32_t) switch_core_debug_level(void); SWITCH_DECLARE(void) switch_cache_db_flush_handles(void); SWITCH_DECLARE(const char *) switch_core_banner(void); SWITCH_DECLARE(switch_bool_t) switch_core_session_in_thread(switch_core_session_t *session); SWITCH_DECLARE(uint32_t) switch_default_ptime(const char *name, uint32_t number); +/*! + \brief Add user registration + \param [in] user + \param [in] realm + \param [in] token + \param [in] url - a freeswitch dial string + \param [in] expires + \param [in] network_ip + \param [in] network_port + \param [in] network_proto - one of tls, tcp, udp + \param [out] err - Error if it exists +*/ SWITCH_DECLARE(switch_status_t) switch_core_add_registration(const char *user, const char *realm, const char *token, const char *url, uint32_t expires, const char *network_ip, const char *network_port, const char *network_proto); +/*! + \brief Delete user registration + \param [in] user + \param [in] realm + \param [in] token + \param [out] err - Error if it exists +*/ SWITCH_DECLARE(switch_status_t) switch_core_del_registration(const char *user, const char *realm, const char *token); +/*! + \brief Expire user registrations + \param [in] force delete all registrations + \param [out] err - Error if it exists +*/ SWITCH_DECLARE(switch_status_t) switch_core_expire_registration(int force); SWITCH_END_EXTERN_C diff --git a/src/include/switch_resample.h b/src/include/switch_resample.h index b38e094dd6..3dff620c4b 100644 --- a/src/include/switch_resample.h +++ b/src/include/switch_resample.h @@ -39,6 +39,7 @@ */ #define switch_normalize_volume(x) if (x > 4) x = 4; if (x < -4) x = -4; +#define switch_normalize_volume_granular(x) if (x > 12) x = 12; if (x < -12) x = -12; #ifndef SWITCH_RESAMPLE_H #define SWITCH_RESAMPLE_H @@ -158,6 +159,14 @@ SWITCH_DECLARE(void) switch_generate_sln_silence(int16_t *data, uint32_t samples \param vol the volume factor -4 -> 4 */ SWITCH_DECLARE(void) switch_change_sln_volume(int16_t *data, uint32_t samples, int32_t vol); + +/*! + \brief Change the volume of a signed linear audio frame with more granularity + \param data the audio data + \param samples the number of 2 byte samples + \param vol the volume factor -12 -> 12 + */ +SWITCH_DECLARE(void) switch_change_sln_volume_granular(int16_t *data, uint32_t samples, int32_t vol); ///\} SWITCH_DECLARE(uint32_t) switch_merge_sln(int16_t *data, uint32_t samples, int16_t *other_data, uint32_t other_samples); diff --git a/src/include/switch_rtp.h b/src/include/switch_rtp.h index 2870bba3af..94c9d671e9 100644 --- a/src/include/switch_rtp.h +++ b/src/include/switch_rtp.h @@ -232,7 +232,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_activate_rtcp(switch_rtp_t *rtp_sessi SWITCH_DECLARE(switch_status_t) switch_rtp_activate_jitter_buffer(switch_rtp_t *rtp_session, uint32_t queue_frames, uint32_t max_queue_frames, - uint32_t samples_per_packet, uint32_t samples_per_second); + uint32_t samples_per_packet, uint32_t samples_per_second, uint32_t max_drift); SWITCH_DECLARE(switch_status_t) switch_rtp_debug_jitter_buffer(switch_rtp_t *rtp_session, const char *name); diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 3972404290..4253d0e542 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -1504,6 +1504,8 @@ typedef enum { SWITCH_EVENT_NAT, SWITCH_EVENT_RECORD_START, SWITCH_EVENT_RECORD_STOP, + SWITCH_EVENT_PLAYBACK_START, + SWITCH_EVENT_PLAYBACK_STOP, SWITCH_EVENT_CALL_UPDATE, SWITCH_EVENT_FAILURE, SWITCH_EVENT_SOCKET_DATA, diff --git a/src/include/switch_utils.h b/src/include/switch_utils.h index a1a93c6ac8..7fcb1e8c75 100644 --- a/src/include/switch_utils.h +++ b/src/include/switch_utils.h @@ -189,10 +189,12 @@ static inline char switch_itodtmf(char i) char r = i; if (i > 9 && i < 14) { - r = i + 55; + r += 55; + } else { + r += 48; } - return r + 48; + return r; } static inline int switch_dtmftoi(char *s) diff --git a/src/mod/applications/mod_callcenter/mod_callcenter.c b/src/mod/applications/mod_callcenter/mod_callcenter.c index 9d9feed0aa..12e1960841 100644 --- a/src/mod/applications/mod_callcenter/mod_callcenter.c +++ b/src/mod/applications/mod_callcenter/mod_callcenter.c @@ -1223,7 +1223,7 @@ static switch_status_t load_agent(const char *agent_name) cc_agent_update("reject_delay_time", reject_delay_time, agent_name); } if (busy_delay_time) { - cc_agent_update("busy_delay_time", reject_delay_time, agent_name); + cc_agent_update("busy_delay_time", busy_delay_time, agent_name); } if (type && res == CC_STATUS_AGENT_ALREADY_EXIST) { diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index 517134d2e1..a6df087cb0 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -90,11 +90,11 @@ static switch_status_t select_url(const char *user, if (exclude_contact) { sql = switch_mprintf("select url, '%q' " - "from registrations where user='%q' and realm='%q' " + "from registrations where reg_user='%q' and realm='%q' " "and url not like '%%%s%%'", (concat != NULL) ? concat : "", user, domain, exclude_contact); } else { sql = switch_mprintf("select url, '%q' " - "from registrations where user='%q' and realm='%q'", + "from registrations where reg_user='%q' and realm='%q'", (concat != NULL) ? concat : "", user, domain); } diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index 5eeae5c781..56c85ad2f3 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -36,7 +36,8 @@ * */ #include -//#define INTENSE_DEBUG +#define DEFAULT_AGC_LEVEL 1100 + SWITCH_MODULE_LOAD_FUNCTION(mod_conference_load); SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_conference_shutdown); SWITCH_MODULE_DEFINITION(mod_conference, mod_conference_load, mod_conference_shutdown, NULL); @@ -194,7 +195,8 @@ typedef enum { EFLAG_BGDIAL_RESULT = (1 << 24), EFLAG_FLOOR_CHANGE = (1 << 25), EFLAG_MUTE_DETECT = (1 << 26), - EFLAG_RECORD = (1 << 27) + EFLAG_RECORD = (1 << 27), + EFLAG_AUTO_GAIN_LEVEL = (1 << 28) } event_type_t; typedef struct conference_file_node { @@ -266,7 +268,6 @@ typedef struct conference_obj { switch_thread_rwlock_t *rwlock; uint32_t count; int32_t energy_level; - int32_t agc_energy_level; uint8_t min; switch_speech_handle_t lsh; switch_speech_handle_t *sh; @@ -312,12 +313,15 @@ struct conference_member { switch_buffer_t *resample_buffer; uint32_t flags; uint32_t score; + uint32_t last_score; uint32_t score_iir; switch_mutex_t *flag_mutex; switch_mutex_t *write_mutex; switch_mutex_t *audio_in_mutex; switch_mutex_t *audio_out_mutex; switch_mutex_t *read_mutex; + switch_thread_rwlock_t *rwlock; + switch_codec_implementation_t read_impl; switch_codec_implementation_t orig_read_impl; switch_codec_t read_codec; switch_codec_t write_codec; @@ -372,6 +376,7 @@ typedef struct api_command { char *pname; void_fn_t pfnapicmd; conference_fntype_t fntype; + char *pcommand; char *psyntax; } api_command_t; @@ -559,6 +564,7 @@ static conference_member_t *conference_member_get(conference_obj_t *conference, member = NULL; } + switch_thread_rwlock_rdlock(member->rwlock); switch_mutex_unlock(conference->member_mutex); return member; @@ -803,6 +809,8 @@ static switch_status_t conference_del_member(conference_obj_t *conference, confe switch_assert(conference != NULL); switch_assert(member != NULL); + switch_thread_rwlock_wrlock(member->rwlock); + lock_member(member); member_fnode = member->fnode; member_sh = member->sh; @@ -831,6 +839,8 @@ static switch_status_t conference_del_member(conference_obj_t *conference, confe last = imember; } + switch_thread_rwlock_unlock(member->rwlock); + /* Close Unused Handles */ if (member_fnode) { conference_file_node_t *fnode, *cur; @@ -1394,6 +1404,7 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v if (switch_test_flag(conference, CFLAG_OUTCALL)) { conference->cancel_cause = SWITCH_CAUSE_ORIGINATOR_CANCEL; + switch_yield(2000000); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Ending pending outcall channels for Conference: '%s'\n", conference->name); while(conference->originating) { switch_yield(200000); @@ -1595,16 +1606,17 @@ static void conference_loop_fn_deafmute_toggle(conference_member_t *member, call static void conference_loop_fn_energy_up(conference_member_t *member, caller_control_action_t *action) { - char msg[512]; + char msg[512], str[30] = ""; switch_event_t *event; + char *p; if (member == NULL) return; lock_member(member); member->energy_level += 200; - if (member->energy_level > 3000) { - member->energy_level = 3000; + if (member->energy_level > 1800) { + member->energy_level = 1800; } if (test_eflag(member->conference, EFLAG_ENERGY_LEVEL) && @@ -1616,13 +1628,23 @@ static void conference_loop_fn_energy_up(conference_member_t *member, caller_con } unlock_member(member); - switch_snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level); - conference_member_say(member, msg, 0); + //switch_snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level); + //conference_member_say(member, msg, 0); + + switch_snprintf(str, sizeof(str), "%d", abs(member->energy_level) / 200); + for (p = str; p && *p; p++) { + switch_snprintf(msg, sizeof(msg), "digits/%c.wav", *p); + conference_member_play_file(member, msg, 0); + } + + + + } static void conference_loop_fn_energy_equ_conf(conference_member_t *member, caller_control_action_t *action) { - char msg[512]; + char msg[512], str[30] = "", *p; switch_event_t *event; if (member == NULL) @@ -1640,20 +1662,27 @@ static void conference_loop_fn_energy_equ_conf(conference_member_t *member, call } unlock_member(member); - switch_snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level); - conference_member_say(member, msg, 0); + //switch_snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level); + //conference_member_say(member, msg, 0); + + switch_snprintf(str, sizeof(str), "%d", abs(member->energy_level) / 200); + for (p = str; p && *p; p++) { + switch_snprintf(msg, sizeof(msg), "digits/%c.wav", *p); + conference_member_play_file(member, msg, 0); + } + } static void conference_loop_fn_energy_dn(conference_member_t *member, caller_control_action_t *action) { - char msg[512]; + char msg[512], str[30] = "", *p; switch_event_t *event; if (member == NULL) return; lock_member(member); - member->energy_level -= 100; + member->energy_level -= 200; if (member->energy_level < 0) { member->energy_level = 0; } @@ -1667,8 +1696,15 @@ static void conference_loop_fn_energy_dn(conference_member_t *member, caller_con } unlock_member(member); - switch_snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level); - conference_member_say(member, msg, 0); + //switch_snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level); + //conference_member_say(member, msg, 0); + + switch_snprintf(str, sizeof(str), "%d", abs(member->energy_level) / 200); + for (p = str; p && *p; p++) { + switch_snprintf(msg, sizeof(msg), "digits/%c.wav", *p); + conference_member_play_file(member, msg, 0); + } + } static void conference_loop_fn_volume_talk_up(conference_member_t *member, caller_control_action_t *action) @@ -1692,8 +1728,17 @@ static void conference_loop_fn_volume_talk_up(conference_member_t *member, calle } unlock_member(member); - switch_snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level); - conference_member_say(member, msg, 0); + //switch_snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level); + //conference_member_say(member, msg, 0); + + if (member->volume_out_level < 0) { + switch_snprintf(msg, sizeof(msg), "currency/negative.wav", member->volume_out_level); + conference_member_play_file(member, msg, 0); + } + + switch_snprintf(msg, sizeof(msg), "digits/%d.wav", abs(member->volume_out_level)); + conference_member_play_file(member, msg, 0); + } static void conference_loop_fn_volume_talk_zero(conference_member_t *member, caller_control_action_t *action) @@ -1716,9 +1761,17 @@ static void conference_loop_fn_volume_talk_zero(conference_member_t *member, cal } unlock_member(member); - switch_snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level); - conference_member_say(member, msg, 0); + //switch_snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level); + //conference_member_say(member, msg, 0); + + if (member->volume_out_level < 0) { + switch_snprintf(msg, sizeof(msg), "currency/negative.wav", member->volume_out_level); + conference_member_play_file(member, msg, 0); + } + + switch_snprintf(msg, sizeof(msg), "digits/%d.wav", abs(member->volume_out_level)); + conference_member_play_file(member, msg, 0); } static void conference_loop_fn_volume_talk_dn(conference_member_t *member, caller_control_action_t *action) @@ -1742,8 +1795,16 @@ static void conference_loop_fn_volume_talk_dn(conference_member_t *member, calle } unlock_member(member); - switch_snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level); - conference_member_say(member, msg, 0); + //switch_snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level); + //conference_member_say(member, msg, 0); + + if (member->volume_out_level < 0) { + switch_snprintf(msg, sizeof(msg), "currency/negative.wav", member->volume_out_level); + conference_member_play_file(member, msg, 0); + } + + switch_snprintf(msg, sizeof(msg), "digits/%d.wav", abs(member->volume_out_level)); + conference_member_play_file(member, msg, 0); } static void conference_loop_fn_volume_listen_up(conference_member_t *member, caller_control_action_t *action) @@ -1767,8 +1828,17 @@ static void conference_loop_fn_volume_listen_up(conference_member_t *member, cal } unlock_member(member); - switch_snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level); - conference_member_say(member, msg, 0); + //switch_snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level); + //conference_member_say(member, msg, 0); + + if (member->volume_in_level < 0) { + switch_snprintf(msg, sizeof(msg), "currency/negative.wav", member->volume_in_level); + conference_member_play_file(member, msg, 0); + } + + switch_snprintf(msg, sizeof(msg), "digits/%d.wav", abs(member->volume_in_level)); + conference_member_play_file(member, msg, 0); + } static void conference_loop_fn_volume_listen_zero(conference_member_t *member, caller_control_action_t *action) @@ -1791,8 +1861,17 @@ static void conference_loop_fn_volume_listen_zero(conference_member_t *member, c } unlock_member(member); - switch_snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level); - conference_member_say(member, msg, 0); + //switch_snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level); + //conference_member_say(member, msg, 0); + + if (member->volume_in_level < 0) { + switch_snprintf(msg, sizeof(msg), "currency/negative.wav", member->volume_in_level); + conference_member_play_file(member, msg, 0); + } + + switch_snprintf(msg, sizeof(msg), "digits/%d.wav", abs(member->volume_in_level)); + conference_member_play_file(member, msg, 0); + } static void conference_loop_fn_volume_listen_dn(conference_member_t *member, caller_control_action_t *action) @@ -1816,8 +1895,16 @@ static void conference_loop_fn_volume_listen_dn(conference_member_t *member, cal } unlock_member(member); - switch_snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level); - conference_member_say(member, msg, 0); + //switch_snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level); + //conference_member_say(member, msg, 0); + + if (member->volume_in_level < 0) { + switch_snprintf(msg, sizeof(msg), "currency/negative.wav", member->volume_in_level); + conference_member_play_file(member, msg, 0); + } + + switch_snprintf(msg, sizeof(msg), "digits/%d.wav", abs(member->volume_in_level)); + conference_member_play_file(member, msg, 0); } static void conference_loop_fn_event(conference_member_t *member, caller_control_action_t *action) @@ -1942,16 +2029,79 @@ static void conference_loop_fn_hangup(conference_member_t *member, caller_contro switch_clear_flag_locked(member, MFLAG_RUNNING); } + +static int noise_gate_check(conference_member_t *member) +{ + int r = 0; + + + if (member->conference->agc_level && member->agc_volume_in_level != 0) { + int target_score = 0; + + target_score = (member->energy_level + (25 * member->agc_volume_in_level)); + + if (target_score < 0) target_score = 0; + + r = member->score > target_score; + + } else { + r = member->score > member->energy_level; + } + + return r; +} + static void clear_avg(conference_member_t *member) { - member->agc_volume_in_level = 0; member->avg_score = 0; member->avg_itt = 0; member->avg_tally = 0; - member->nt_tally = 0; + member->agc_concur = 0; } +static void check_agc_levels(conference_member_t *member) +{ + int x = 0, y = member->agc_volume_in_level; + + if (!member->avg_score) return; + + if (member->avg_score < member->conference->agc_level - 100) { + member->agc_volume_in_level++; + switch_normalize_volume_granular(member->agc_volume_in_level); + x = 1; + } else if (member->avg_score > member->conference->agc_level + 100) { + member->agc_volume_in_level--; + switch_normalize_volume_granular(member->agc_volume_in_level); + x = -1; + } + + if (x) { + switch_event_t *event; + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG7, + "AGC %s:%d diff:%d level:%d cur:%d avg:%d vol:%d %s\n", + member->conference->name, + member->id, member->conference->agc_level - member->avg_score, member->conference->agc_level, + member->score, member->avg_score, member->agc_volume_in_level, x > 0 ? "+++" : "---"); + + clear_avg(member); + + + if (test_eflag(member->conference, EFLAG_AUTO_GAIN_LEVEL) && + switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) { + conference_add_event_member_data(member, event); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "auto-gain-level"); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Old-Level", "%d", y); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Level", "%d", member->agc_volume_in_level); + switch_event_fire(&event); + } + + } +} + + + /* marshall frames from the call leg to the conference thread for muxing to other call legs */ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, void *obj) @@ -1961,8 +2111,7 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v switch_channel_t *channel; switch_status_t status; switch_frame_t *read_frame = NULL; - uint32_t hangover = 40, hangunder = 5, hangover_hits = 0, hangunder_hits = 0, energy_level = 0, diff_level = 400; - switch_codec_implementation_t read_impl = { 0 }; + uint32_t hangover = 40, hangunder = 5, hangover_hits = 0, hangunder_hits = 0, diff_level = 400; switch_core_session_t *session = member->session; int check_floor_change; @@ -1972,7 +2121,7 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v channel = switch_core_session_get_channel(session); - switch_core_session_get_read_impl(session, &read_impl); + switch_core_session_get_read_impl(session, &member->read_impl); /* As long as we have a valid read, feed that data into an input buffer where the conference thread will take it and mux it with any audio from other channels. */ @@ -1997,6 +2146,10 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v } if (switch_test_flag(read_frame, SFF_CNG)) { + if (member->conference->agc_level) { + member->nt_tally++; + } + if (hangunder_hits) { hangunder_hits--; } @@ -2004,6 +2157,7 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v if (++hangover_hits >= hangover) { hangover_hits = hangunder_hits = 0; switch_clear_flag_locked(member, MFLAG_TALKING); + check_agc_levels(member); clear_avg(member); if (test_eflag(member->conference, EFLAG_STOP_TALKING) && @@ -2017,46 +2171,45 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v goto do_continue; } - + + if (member->nt_tally > (member->read_impl.actual_samples_per_second / member->read_impl.samples_per_packet) * 3) { + member->agc_volume_in_level = 0; + clear_avg(member); + } + /* Check for input volume adjustments */ if (!member->conference->agc_level) { + member->conference->agc_level = 0; clear_avg(member); } - energy_level = member->energy_level; /* if the member can speak, compute the audio energy level and */ /* generate events when the level crosses the threshold */ if ((switch_test_flag(member, MFLAG_CAN_SPEAK) || switch_test_flag(member, MFLAG_MUTE_DETECT))) { uint32_t energy = 0, i = 0, samples = 0, j = 0; int16_t *data; - int divisor = 0; - int agc_period = (read_impl.actual_samples_per_second / read_impl.samples_per_packet) / 2; - int combined_vol = 0; + int agc_period = (member->read_impl.actual_samples_per_second / member->read_impl.samples_per_packet) / 4; + data = read_frame->data; - - if (!(divisor = read_impl.actual_samples_per_second / 8000)) { - divisor = 1; - } - member->score = 0; - combined_vol = member->agc_volume_in_level; - if (member->conference->agc_level) { - combined_vol += member->agc_volume_in_level; + if (member->volume_in_level) { + switch_change_sln_volume(read_frame->data, read_frame->datalen / 2, member->volume_in_level); } - if (combined_vol) { - switch_change_sln_volume(read_frame->data, read_frame->datalen / 2, combined_vol); + if (member->agc_volume_in_level) { + switch_change_sln_volume_granular(read_frame->data, read_frame->datalen / 2, member->agc_volume_in_level); } if ((samples = read_frame->datalen / sizeof(*data))) { for (i = 0; i < samples; i++) { energy += abs(data[j]); - j += read_impl.number_of_channels; + j += member->read_impl.number_of_channels; } - member->score = energy / (samples / divisor); + + member->score = energy / samples; } if (member->vol_period) { @@ -2065,39 +2218,37 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v if (member->conference->agc_level && member->score && switch_test_flag(member, MFLAG_CAN_SPEAK) && - member->score > member->conference->agc_energy_level + noise_gate_check(member) ) { - - member->avg_tally += member->score; - member->avg_itt++; - if (!member->avg_itt) member->avg_itt++; - member->avg_score = member->avg_tally / member->avg_itt; + int last_shift = abs(member->last_score - member->score); + if (member->score && member->last_score && last_shift > 900) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG7, + "AGC %s:%d drop anomalous shift of %d\n", + member->conference->name, + member->id, last_shift); + + } else { + member->avg_tally += member->score; + member->avg_itt++; + if (!member->avg_itt) member->avg_itt++; + member->avg_score = member->avg_tally / member->avg_itt; + } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG7, - "conf %s AGC %d %d %d %d %d %d\n", + "AGC %s:%d diff:%d level:%d cur:%d avg:%d vol:%d\n", member->conference->name, member->id, member->conference->agc_level - member->avg_score, member->conference->agc_level, member->score, member->avg_score, member->agc_volume_in_level); - - - if (++member->nt_tally >= agc_period) { + if (++member->agc_concur >= agc_period) { if (!member->vol_period) { - if (member->avg_score < member->conference->agc_level) { - member->agc_volume_in_level++; - switch_normalize_volume(member->agc_volume_in_level); - member->vol_period = (read_impl.actual_samples_per_second / read_impl.samples_per_packet) * 2; - } - - if (member->avg_score > member->conference->agc_level) { - member->agc_volume_in_level--; - switch_normalize_volume(member->agc_volume_in_level); - member->vol_period = (read_impl.actual_samples_per_second / read_impl.samples_per_packet) * 2; - } + check_agc_levels(member); } - member->nt_tally = 0; + member->agc_concur = 0; } + } else { + member->nt_tally++; } member->score_iir = (int) (((1.0 - SCORE_DECAY) * (float) member->score) + (SCORE_DECAY * (float) member->score_iir)); @@ -2106,12 +2257,16 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v member->score_iir = SCORE_MAX_IIR; } - if (member->score > energy_level) { - uint32_t diff = member->score - energy_level; + if (noise_gate_check(member)) { + uint32_t diff = member->score - member->energy_level; if (hangover_hits) { hangover_hits--; } + if (member->conference->agc_level) { + member->nt_tally = 0; + } + if (diff >= diff_level || ++hangunder_hits >= hangunder) { check_floor_change = 1; @@ -2147,13 +2302,19 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v if (hangunder_hits) { hangunder_hits--; } + + if (member->conference->agc_level) { + member->nt_tally++; + } + if (switch_test_flag(member, MFLAG_TALKING) && switch_test_flag(member, MFLAG_CAN_SPEAK)) { switch_event_t *event; if (++hangover_hits >= hangover) { hangover_hits = hangunder_hits = 0; switch_clear_flag_locked(member, MFLAG_TALKING); + check_agc_levels(member); clear_avg(member); - + if (test_eflag(member->conference, EFLAG_STOP_TALKING) && switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) { conference_add_event_member_data(member, event); @@ -2163,10 +2324,13 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v } } } + + + member->last_score = member->score; } /* skip frames that are not actual media or when we are muted or silent */ - if ((switch_test_flag(member, MFLAG_TALKING) || energy_level == 0) && switch_test_flag(member, MFLAG_CAN_SPEAK) && + if ((switch_test_flag(member, MFLAG_TALKING) || member->energy_level == 0) && switch_test_flag(member, MFLAG_CAN_SPEAK) && !switch_test_flag(member->conference, CFLAG_WAIT_MOD)) { switch_audio_resampler_t *read_resampler = member->read_resampler; void *data; @@ -2689,6 +2853,7 @@ static void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t *th switch_mutex_init(&member->audio_in_mutex, SWITCH_MUTEX_NESTED, rec->pool); switch_mutex_init(&member->audio_out_mutex, SWITCH_MUTEX_NESTED, rec->pool); switch_mutex_init(&member->read_mutex, SWITCH_MUTEX_NESTED, rec->pool); + switch_thread_rwlock_create(&member->rwlock, rec->pool); /* Setup an audio buffer for the incoming audio */ if (switch_buffer_create_dynamic(&member->audio_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, 0) != SWITCH_STATUS_SUCCESS) { @@ -3295,6 +3460,30 @@ static void conference_member_itterator(conference_obj_t *conference, switch_str switch_mutex_unlock(conference->member_mutex); } + +static switch_status_t list_conferences(const char *line, const char *cursor, switch_console_callback_match_t **matches) +{ + switch_console_callback_match_t *my_matches = NULL; + switch_status_t status = SWITCH_STATUS_FALSE; + switch_hash_index_t *hi; + void *val; + const void *vvar; + + switch_mutex_lock(globals.hash_mutex); + for (hi = switch_hash_first(NULL, globals.conference_hash); hi; hi = switch_hash_next(hi)) { + switch_hash_this(hi, &vvar, NULL, &val); + switch_console_push_match(&my_matches, (const char *) vvar); + } + switch_mutex_unlock(globals.hash_mutex); + + if (my_matches) { + *matches = my_matches; + status = SWITCH_STATUS_SUCCESS; + } + + return status; +} + static void conference_list_pretty(conference_obj_t *conference, switch_stream_handle_t *stream) { conference_member_t *member = NULL; @@ -3374,8 +3563,11 @@ static void conference_list(conference_obj_t *conference, switch_stream_handle_t count++; } - stream->write_function(stream, "%s%d%s%d%s%d\n", delim, member->agc_volume_in_level ? - member->agc_volume_in_level : member->volume_in_level, delim, member->volume_out_level, delim, member->energy_level); + stream->write_function(stream, "%s%d%s%d%s%d%s%d\n", delim, + member->volume_in_level, + delim, + member->agc_volume_in_level, + delim, member->volume_out_level, delim, member->energy_level); } switch_mutex_unlock(conference->member_mutex); @@ -3389,6 +3581,9 @@ static switch_status_t conf_api_sub_mute(conference_member_t *member, switch_str return SWITCH_STATUS_GENERR; switch_clear_flag_locked(member, MFLAG_CAN_SPEAK); + switch_clear_flag_locked(member, MFLAG_TALKING); + + if (!zstr(member->conference->muted_sound)) { conference_member_play_file(member, member->conference->muted_sound, 0); } else { @@ -3412,7 +3607,7 @@ static switch_status_t conf_api_sub_mute(conference_member_t *member, switch_str static switch_status_t conf_api_sub_agc(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv) { - int level, energy_level; + int level; int on = 0; if (argc == 2) { @@ -3430,13 +3625,7 @@ static switch_status_t conf_api_sub_agc(conference_obj_t *conference, switch_str if (argc > 3) { level = atoi(argv[3]); } else { - level = 650; - } - - if (argc > 4) { - energy_level = atoi(argv[4]); - } else { - energy_level = 100; + level = DEFAULT_AGC_LEVEL; } if (level > conference->energy_level) { @@ -3444,10 +3633,9 @@ static switch_status_t conf_api_sub_agc(conference_obj_t *conference, switch_str conference->avg_itt = 0; conference->avg_tally = 0; conference->agc_level = level; - conference->agc_energy_level = energy_level; if (stream) { - stream->write_function(stream, "OK AGC ENABLED %d %d\n", conference->agc_level, conference->agc_energy_level); + stream->write_function(stream, "OK AGC ENABLED %d\n", conference->agc_level); } } else { @@ -3821,7 +4009,7 @@ static void conference_xlist(conference_obj_t *conference, switch_xml_t x_confer if (conference->agc_level) { char tmp[30] = ""; - switch_snprintf(tmp, sizeof(tmp), "%d:%d", conference->agc_level, conference->agc_energy_level); + switch_snprintf(tmp, sizeof(tmp), "%d", conference->agc_level); switch_xml_set_attr_d_buf(x_conference, "agc", tmp); } @@ -3909,9 +4097,8 @@ static void conference_xlist(conference_obj_t *conference, switch_xml_t x_confer switch_snprintf(tmp, sizeof(tmp), "%d", member->agc_volume_in_level ? member->agc_volume_in_level : member->volume_in_level); x_tag = add_x_tag(x_member, "input-volume", tmp, toff++); - if (member->agc_volume_in_level) { - switch_xml_set_attr_d(x_tag, "auto", "true"); - } + switch_snprintf(tmp, sizeof(tmp), "%d", member->agc_volume_in_level); + x_tag = add_x_tag(x_member, "auto-adjusted-input-volume", tmp, toff++); } @@ -4007,6 +4194,7 @@ static switch_status_t conf_api_sub_play(conference_obj_t *conference, switch_st } else { stream->write_function(stream, "(play) File: %s not found.\n", argv[2] ? argv[2] : "(unspecified)"); } + switch_thread_rwlock_unlock(member->rwlock); ret_status = SWITCH_STATUS_SUCCESS; } else { stream->write_function(stream, "Member: %u not found.\n", id); @@ -4047,7 +4235,7 @@ static switch_status_t conf_api_sub_saymember(conference_obj_t *conference, swit char *start_text = NULL; char *workspace = NULL; uint32_t id = 0; - conference_member_t *member; + conference_member_t *member = NULL; switch_event_t *event; if (zstr(text)) { @@ -4099,6 +4287,11 @@ static switch_status_t conf_api_sub_saymember(conference_obj_t *conference, swit ret_status = SWITCH_STATUS_SUCCESS; done: + + if (member) { + switch_thread_rwlock_unlock(member->rwlock); + } + switch_safe_free(workspace); switch_safe_free(expanded); return ret_status; @@ -4129,6 +4322,7 @@ static switch_status_t conf_api_sub_stop(conference_obj_t *conference, switch_st if ((member = conference_member_get(conference, id))) { uint32_t stopped = conference_member_stop_file(member, async ? FILE_STOP_ASYNC : current ? FILE_STOP_CURRENT : FILE_STOP_ALL); stream->write_function(stream, "Stopped %u files.\n", stopped); + switch_thread_rwlock_unlock(member->rwlock); } else { stream->write_function(stream, "Member: %u not found.\n", id); } @@ -4168,6 +4362,7 @@ static switch_status_t conf_api_sub_relate(conference_obj_t *conference, switch_ if ((member = conference_member_get(conference, id))) { member_del_relationship(member, oid); stream->write_function(stream, "relationship %u->%u cleared.\n", id, oid); + switch_thread_rwlock_unlock(member->rwlock); } else { stream->write_function(stream, "relationship %u->%u not found.\n", id, oid); } @@ -4179,9 +4374,13 @@ static switch_status_t conf_api_sub_relate(conference_obj_t *conference, switch_ uint32_t id = atoi(argv[2]); uint32_t oid = atoi(argv[3]); - if ((member = conference_member_get(conference, id)) - && (other_member = conference_member_get(conference, oid))) { + if ((member = conference_member_get(conference, id))) { + other_member = conference_member_get(conference, oid); + } + + if (member && other_member) { conference_relationship_t *rel = NULL; + if ((rel = member_get_relationship(member, other_member))) { rel->flags = 0; } else { @@ -4192,6 +4391,7 @@ static switch_status_t conf_api_sub_relate(conference_obj_t *conference, switch_ switch_set_flag(rel, RFLAG_CAN_SPEAK | RFLAG_CAN_HEAR); if (nospeak) { switch_clear_flag(rel, RFLAG_CAN_SPEAK); + switch_clear_flag_locked(member, MFLAG_TALKING); } if (nohear) { switch_clear_flag(rel, RFLAG_CAN_HEAR); @@ -4203,6 +4403,14 @@ static switch_status_t conf_api_sub_relate(conference_obj_t *conference, switch_ } else { stream->write_function(stream, "relationship %u->%u not found.\n", id, oid); } + + if (member) { + switch_thread_rwlock_unlock(member->rwlock); + } + + if (other_member) { + switch_thread_rwlock_unlock(other_member->rwlock); + } } return SWITCH_STATUS_SUCCESS; @@ -4357,6 +4565,7 @@ static switch_status_t conf_api_sub_transfer(conference_obj_t *conference, switc /* Setup a memory pool to use. */ if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n"); + switch_thread_rwlock_unlock(member->rwlock); goto done; } @@ -4369,6 +4578,7 @@ static switch_status_t conf_api_sub_transfer(conference_obj_t *conference, switc /* Open the config from the xml registry */ if (!(cxml = switch_xml_open_cfg(global_cf_name, &cfg, params))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", global_cf_name); + switch_thread_rwlock_unlock(member->rwlock); goto done; } @@ -4390,6 +4600,7 @@ static switch_status_t conf_api_sub_transfer(conference_obj_t *conference, switc if (pool != NULL) { switch_core_destroy_memory_pool(&pool); } + switch_thread_rwlock_unlock(member->rwlock); goto done; } @@ -4450,6 +4661,10 @@ static switch_status_t conf_api_sub_transfer(conference_obj_t *conference, switc switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "transfer"); switch_event_fire(&event); } + + if (member) { + switch_thread_rwlock_unlock(member->rwlock); + } } if (new_conference) { @@ -4569,41 +4784,32 @@ typedef enum { /* API Interface Function sub-commands */ /* Entries in this list should be kept in sync with the enum above */ static api_command_t conf_api_sub_commands[] = { - {"list", (void_fn_t) & conf_api_sub_list, CONF_API_SUB_ARGS_SPLIT, " list [delim ]"}, - {"xml_list", (void_fn_t) & conf_api_sub_xml_list, CONF_API_SUB_ARGS_SPLIT, " xml_list"}, - {"energy", (void_fn_t) & conf_api_sub_energy, CONF_API_SUB_MEMBER_TARGET, - " energy []"}, - {"volume_in", (void_fn_t) & conf_api_sub_volume_in, CONF_API_SUB_MEMBER_TARGET, - " volume_in []"}, - {"volume_out", (void_fn_t) & conf_api_sub_volume_out, CONF_API_SUB_MEMBER_TARGET, - " volume_out []"}, - {"play", (void_fn_t) & conf_api_sub_play, CONF_API_SUB_ARGS_SPLIT, " play [async|]"}, - {"say", (void_fn_t) & conf_api_sub_say, CONF_API_SUB_ARGS_AS_ONE, " say "}, - {"saymember", (void_fn_t) & conf_api_sub_saymember, CONF_API_SUB_ARGS_AS_ONE, - " saymember "}, - {"stop", (void_fn_t) & conf_api_sub_stop, CONF_API_SUB_ARGS_SPLIT, - " stop <[current|all|async|last]> []"}, - {"dtmf", (void_fn_t) & conf_api_sub_dtmf, CONF_API_SUB_MEMBER_TARGET, - " dtmf <[member_id|all|last]> "}, - {"kick", (void_fn_t) & conf_api_sub_kick, CONF_API_SUB_MEMBER_TARGET, " kick <[member_id|all|last]>"}, - {"mute", (void_fn_t) & conf_api_sub_mute, CONF_API_SUB_MEMBER_TARGET, " mute <[member_id|all]|last>"}, - {"unmute", (void_fn_t) & conf_api_sub_unmute, CONF_API_SUB_MEMBER_TARGET, " unmute <[member_id|all]|last>"}, - {"deaf", (void_fn_t) & conf_api_sub_deaf, CONF_API_SUB_MEMBER_TARGET, " deaf <[member_id|all]|last>"}, - {"undeaf", (void_fn_t) & conf_api_sub_undeaf, CONF_API_SUB_MEMBER_TARGET, " undeaf <[member_id|all]|last>"}, - {"relate", (void_fn_t) & conf_api_sub_relate, CONF_API_SUB_ARGS_SPLIT, " relate [nospeak|nohear|clear]"}, - {"lock", (void_fn_t) & conf_api_sub_lock, CONF_API_SUB_ARGS_SPLIT, " lock"}, - {"unlock", (void_fn_t) & conf_api_sub_unlock, CONF_API_SUB_ARGS_SPLIT, " unlock"}, - {"agc", (void_fn_t) & conf_api_sub_agc, CONF_API_SUB_ARGS_SPLIT, " agc"}, - {"dial", (void_fn_t) & conf_api_sub_dial, CONF_API_SUB_ARGS_SPLIT, - " dial / "}, - {"bgdial", (void_fn_t) & conf_api_sub_bgdial, CONF_API_SUB_ARGS_SPLIT, - " bgdial / "}, - {"transfer", (void_fn_t) & conf_api_sub_transfer, CONF_API_SUB_ARGS_SPLIT, - " transfer [...]"}, - {"record", (void_fn_t) & conf_api_sub_record, CONF_API_SUB_ARGS_SPLIT, " record "}, - {"norecord", (void_fn_t) & conf_api_sub_norecord, CONF_API_SUB_ARGS_SPLIT, " norecord <[filename|all]>"}, - {"pin", (void_fn_t) & conf_api_sub_pin, CONF_API_SUB_ARGS_SPLIT, " pin "}, - {"nopin", (void_fn_t) & conf_api_sub_pin, CONF_API_SUB_ARGS_SPLIT, " nopin"}, + {"list", (void_fn_t) & conf_api_sub_list, CONF_API_SUB_ARGS_SPLIT, "list", "[delim ]"}, + {"xml_list", (void_fn_t) & conf_api_sub_xml_list, CONF_API_SUB_ARGS_SPLIT, "xml_list", ""}, + {"energy", (void_fn_t) & conf_api_sub_energy, CONF_API_SUB_MEMBER_TARGET, "energy", " []"}, + {"volume_in", (void_fn_t) & conf_api_sub_volume_in, CONF_API_SUB_MEMBER_TARGET, "volume_in", " []"}, + {"volume_out", (void_fn_t) & conf_api_sub_volume_out, CONF_API_SUB_MEMBER_TARGET, "volume_out", " []"}, + {"play", (void_fn_t) & conf_api_sub_play, CONF_API_SUB_ARGS_SPLIT, "play", " [async|]"}, + {"say", (void_fn_t) & conf_api_sub_say, CONF_API_SUB_ARGS_AS_ONE, "say", ""}, + {"saymember", (void_fn_t) & conf_api_sub_saymember, CONF_API_SUB_ARGS_AS_ONE, "saymember", " "}, + {"stop", (void_fn_t) & conf_api_sub_stop, CONF_API_SUB_ARGS_SPLIT, "stop", "<[current|all|async|last]> []"}, + {"dtmf", (void_fn_t) & conf_api_sub_dtmf, CONF_API_SUB_MEMBER_TARGET, "dtmf", "<[member_id|all|last]> "}, + {"kick", (void_fn_t) & conf_api_sub_kick, CONF_API_SUB_MEMBER_TARGET, "kick", "<[member_id|all|last]>"}, + {"mute", (void_fn_t) & conf_api_sub_mute, CONF_API_SUB_MEMBER_TARGET, "mute", "<[member_id|all]|last>"}, + {"unmute", (void_fn_t) & conf_api_sub_unmute, CONF_API_SUB_MEMBER_TARGET, "unmute", "<[member_id|all]|last>"}, + {"deaf", (void_fn_t) & conf_api_sub_deaf, CONF_API_SUB_MEMBER_TARGET, "deaf", "<[member_id|all]|last>"}, + {"undeaf", (void_fn_t) & conf_api_sub_undeaf, CONF_API_SUB_MEMBER_TARGET, "undeaf", "<[member_id|all]|last>"}, + {"relate", (void_fn_t) & conf_api_sub_relate, CONF_API_SUB_ARGS_SPLIT, "relate", " [nospeak|nohear|clear]"}, + {"lock", (void_fn_t) & conf_api_sub_lock, CONF_API_SUB_ARGS_SPLIT, "lock", ""}, + {"unlock", (void_fn_t) & conf_api_sub_unlock, CONF_API_SUB_ARGS_SPLIT, "unlock", ""}, + {"agc", (void_fn_t) & conf_api_sub_agc, CONF_API_SUB_ARGS_SPLIT, "agc", ""}, + {"dial", (void_fn_t) & conf_api_sub_dial, CONF_API_SUB_ARGS_SPLIT, "dial", "/ "}, + {"bgdial", (void_fn_t) & conf_api_sub_bgdial, CONF_API_SUB_ARGS_SPLIT, "bgdial", "/ "}, + {"transfer", (void_fn_t) & conf_api_sub_transfer, CONF_API_SUB_ARGS_SPLIT, "transfer", " [...]"}, + {"record", (void_fn_t) & conf_api_sub_record, CONF_API_SUB_ARGS_SPLIT, "record", ""}, + {"norecord", (void_fn_t) & conf_api_sub_norecord, CONF_API_SUB_ARGS_SPLIT, "norecord", "<[filename|all]>"}, + {"pin", (void_fn_t) & conf_api_sub_pin, CONF_API_SUB_ARGS_SPLIT, "pin", ""}, + {"nopin", (void_fn_t) & conf_api_sub_pin, CONF_API_SUB_ARGS_SPLIT, "nopin", ""}, }; #define CONFFUNCAPISIZE (sizeof(conf_api_sub_commands)/sizeof(conf_api_sub_commands[0])) @@ -4628,7 +4834,7 @@ switch_status_t conf_api_dispatch(conference_obj_t *conference, switch_stream_ha if (pfn(conference, stream, argc, argv) != SWITCH_STATUS_SUCCESS) { /* command returned error, so show syntax usage */ - stream->write_function(stream, conf_api_sub_commands[i].psyntax); + stream->write_function(stream, "%s %s", conf_api_sub_commands[i].pcommand, conf_api_sub_commands[i].psyntax); } } break; @@ -4677,11 +4883,12 @@ switch_status_t conf_api_dispatch(conference_obj_t *conference, switch_stream_ha if (member != NULL) { pfn(member, stream, argv[argn + 2]); + switch_thread_rwlock_unlock(member->rwlock); } else { stream->write_function(stream, "Non-Existant ID %u\n", id); } } else { - stream->write_function(stream, conf_api_sub_commands[i].psyntax); + stream->write_function(stream, "%s %s", conf_api_sub_commands[i].pcommand, conf_api_sub_commands[i].psyntax); } } break; @@ -4704,7 +4911,7 @@ switch_status_t conf_api_dispatch(conference_obj_t *conference, switch_stream_ha /* call the command handler */ if (pfn(conference, stream, modified_cmdline) != SWITCH_STATUS_SUCCESS) { /* command returned error, so show syntax usage */ - stream->write_function(stream, conf_api_sub_commands[i].psyntax); + stream->write_function(stream, "%s %s", conf_api_sub_commands[i].pcommand, conf_api_sub_commands[i].psyntax); } } break; @@ -4779,12 +4986,14 @@ SWITCH_STANDARD_API(conf_api_main) } else if (argv[1] && strcasecmp(argv[1], "dial") == 0) { if (conf_api_sub_dial(NULL, stream, argc, argv) != SWITCH_STATUS_SUCCESS) { /* command returned error, so show syntax usage */ - stream->write_function(stream, conf_api_sub_commands[CONF_API_COMMAND_DIAL].psyntax); + stream->write_function(stream, "%s %s", conf_api_sub_commands[CONF_API_COMMAND_DIAL].pcommand, + conf_api_sub_commands[CONF_API_COMMAND_DIAL].psyntax); } } else if (argv[1] && strcasecmp(argv[1], "bgdial") == 0) { if (conf_api_sub_bgdial(NULL, stream, argc, argv) != SWITCH_STATUS_SUCCESS) { /* command returned error, so show syntax usage */ - stream->write_function(stream, conf_api_sub_commands[CONF_API_COMMAND_BGDIAL].psyntax); + stream->write_function(stream, "%s %s", conf_api_sub_commands[CONF_API_COMMAND_BGDIAL].pcommand, + conf_api_sub_commands[CONF_API_COMMAND_BGDIAL].psyntax); } } else { stream->write_function(stream, "Conference %s not found\n", argv[0]); @@ -4792,7 +5001,11 @@ SWITCH_STANDARD_API(conf_api_main) } } else { - stream->write_function(stream, "No parameters specified.\nTry 'help conference'\n"); + int i; + + for (i = 0; i < CONFFUNCAPISIZE; i++) { + stream->write_function(stream, " %s %s\n", conf_api_sub_commands[i].pcommand, conf_api_sub_commands[i].psyntax); + } } done: @@ -5127,6 +5340,7 @@ static void set_mflags(const char *flags, member_flag_t *f) for (i = 0; i < argc && argv[i]; i++) { if (!strcasecmp(argv[i], "mute")) { *f &= ~MFLAG_CAN_SPEAK; + *f &= ~MFLAG_TALKING; } else if (!strcasecmp(argv[i], "deaf")) { *f &= ~MFLAG_CAN_HEAR; } else if (!strcasecmp(argv[i], "waste")) { @@ -5785,6 +5999,7 @@ SWITCH_STANDARD_APP(conference_function) switch_mutex_init(&member.read_mutex, SWITCH_MUTEX_NESTED, member.pool); switch_mutex_init(&member.audio_in_mutex, SWITCH_MUTEX_NESTED, member.pool); switch_mutex_init(&member.audio_out_mutex, SWITCH_MUTEX_NESTED, member.pool); + switch_thread_rwlock_create(&member.rwlock, member.pool); /* Install our Signed Linear codec so we get the audio in that format */ switch_core_session_set_read_codec(member.session, &member.read_codec); @@ -6208,6 +6423,7 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_c comfort_noise_level = 1400; } } else if (!strcasecmp(var, "sound-prefix") && !zstr(val)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "override sound-prefix with: %s\n", val); sound_prefix = val; } else if (!strcasecmp(var, "max-members") && !zstr(val)) { errno = 0; /* sanity first */ @@ -6312,8 +6528,15 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_c set_cflags(conference_flags, &conference->flags); } - if (sound_prefix) { + if (!zstr(sound_prefix)) { conference->sound_prefix = switch_core_strdup(conference->pool, sound_prefix); + } else { + const char *val; + if ((val = switch_channel_get_variable(channel, "sound_prefix")) && !zstr(val)) { + /* if no sound_prefix was set, use the channel sound_prefix */ + conference->sound_prefix = switch_core_strdup(conference->pool, val); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "using channel sound prefix: %s\n", conference->sound_prefix); + } } if (!zstr(enter_sound)) { @@ -6389,30 +6612,16 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_c if (!zstr(auto_gain_level)) { int level = 0; - int energy_level = 100; if (switch_true(auto_gain_level)) { - level = 650; + level = DEFAULT_AGC_LEVEL; } else { - char *p; - int tmp = 0; - level = atoi(auto_gain_level); - if ((p = strchr(auto_gain_level, ':'))) { - p++; - if (p) tmp = atoi(p); - if (tmp > 0) { - energy_level = tmp; - } - } } if (level > 0 && level > conference->energy_level) { conference->agc_level = level; } - - conference->agc_energy_level = energy_level; - } if (!zstr(maxmember_sound)) { @@ -6717,16 +6926,25 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_conference_load) switch_api_interface_t *api_interface; switch_application_interface_t *app_interface; switch_status_t status = SWITCH_STATUS_SUCCESS; + char cmd_str[256]; memset(&globals, 0, sizeof(globals)); /* Connect my internal structure to the blank pointer passed to me */ *module_interface = switch_loadable_module_create_module_interface(pool, modname); + switch_console_add_complete_func("::conference::list_conferences", list_conferences); + + /* build api interface help ".syntax" field string */ p = strdup(""); for (i = 0; i < CONFFUNCAPISIZE; i++) { - nl = strlen(conf_api_sub_commands[i].psyntax) + 4; + nl = strlen(conf_api_sub_commands[i].pcommand) + strlen(conf_api_sub_commands[i].psyntax) + 5; + + switch_snprintf(cmd_str, sizeof(cmd_str), "add conference ::conference::list_conferences %s", conf_api_sub_commands[i].pcommand); + + switch_console_set_complete(cmd_str); + if (p != NULL) { ol = strlen(p); } @@ -6734,7 +6952,11 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_conference_load) if (tmp != NULL) { p = tmp; strcat(p, "\t\t"); - strcat(p, conf_api_sub_commands[i].psyntax); + strcat(p, conf_api_sub_commands[i].pcommand); + if (!zstr(conf_api_sub_commands[i].psyntax)) { + strcat(p, " "); + strcat(p, conf_api_sub_commands[i].psyntax); + } if (i < CONFFUNCAPISIZE - 1) { strcat(p, "\n"); } @@ -6773,6 +6995,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_conference_load) SWITCH_ADD_APP(app_interface, global_app_name, global_app_name, NULL, conference_function, NULL, SAF_NONE); SWITCH_ADD_APP(app_interface, "conference_set_auto_outcall", "conference_set_auto_outcall", NULL, conference_auto_function, NULL, SAF_NONE); SWITCH_ADD_CHAT(chat_interface, CONF_CHAT_PROTO, chat_send); + send_presence(SWITCH_EVENT_PRESENCE_IN); @@ -6788,6 +7011,8 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_conference_shutdown) /* signal all threads to shutdown */ globals.running = 0; + switch_console_del_complete_func("::conference::list_conferences"); + /* wait for all threads */ while (globals.threads) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Waiting for %d threads\n", globals.threads); diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index 9a1258a5b6..346cdaa9f8 100755 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -2893,7 +2893,7 @@ static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session, switch_xml_t x_domain = NULL, xml = NULL, x_user = NULL, x_group = NULL, x_param, x_params; char *user = NULL, *domain = NULL, *dup_domain = NULL; const char *dest = NULL; - static switch_call_cause_t cause = SWITCH_CAUSE_NONE; + switch_call_cause_t cause = SWITCH_CAUSE_NONE; unsigned int timelimit = 60; switch_channel_t *new_channel = NULL; switch_event_t *params = NULL, *var_event_orig = var_event; diff --git a/src/mod/applications/mod_lcr/mod_lcr.c b/src/mod/applications/mod_lcr/mod_lcr.c index 2f2bc7d421..593117942a 100644 --- a/src/mod/applications/mod_lcr/mod_lcr.c +++ b/src/mod/applications/mod_lcr/mod_lcr.c @@ -595,11 +595,12 @@ static int route_add_callback(void *pArg, int argc, char **argv, char **columnNa callback_t *cbt = (callback_t *) pArg; char *key = NULL; int i = 0; + int r = 0; switch_memory_pool_t *pool = cbt->pool; additional = switch_core_alloc(pool, sizeof(lcr_obj_t)); - additional->fields = switch_core_alloc(pool, sizeof(switch_event_t)); + switch_event_create(&additional->fields, SWITCH_EVENT_REQUEST_PARAMS); for (i = 0; i < argc ; i++) { if (CF("lcr_digits")) { @@ -652,9 +653,9 @@ static int route_add_callback(void *pArg, int argc, char **argv, char **columnNa switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Adding %s to head of list\n", additional->carrier_name); if (switch_core_hash_insert(cbt->dedup_hash, key, additional) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error inserting into dedup hash\n"); - return SWITCH_STATUS_GENERR; + r = -1; goto end; } - return SWITCH_STATUS_SUCCESS; + r = 0; goto end; } @@ -676,7 +677,7 @@ static int route_add_callback(void *pArg, int argc, char **argv, char **columnNa additional->prev = current; if (switch_core_hash_insert(cbt->dedup_hash, key, additional) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error inserting into dedup hash\n"); - return SWITCH_STATUS_GENERR; + r = -1; goto end; } break; } @@ -697,7 +698,7 @@ static int route_add_callback(void *pArg, int argc, char **argv, char **columnNa current->prev = additional; if (switch_core_hash_insert(cbt->dedup_hash, key, additional) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error inserting into dedup hash\n"); - return SWITCH_STATUS_GENERR; + r = -1; goto end; } break; } else if (current->next == NULL) { @@ -707,13 +708,19 @@ static int route_add_callback(void *pArg, int argc, char **argv, char **columnNa additional->prev = current; if (switch_core_hash_insert(cbt->dedup_hash, key, additional) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error inserting into dedup hash\n"); - return SWITCH_STATUS_GENERR; + r = -1; goto end; } break; } } } - return SWITCH_STATUS_SUCCESS; + + end: + + switch_event_destroy(&additional->fields); + + return r; + } static int intrastatelata_callback(void *pArg, int argc, char **argv, char **columnNames) diff --git a/src/mod/applications/mod_valet_parking/mod_valet_parking.c b/src/mod/applications/mod_valet_parking/mod_valet_parking.c index 42ece97e28..14412bc318 100644 --- a/src/mod/applications/mod_valet_parking/mod_valet_parking.c +++ b/src/mod/applications/mod_valet_parking/mod_valet_parking.c @@ -114,7 +114,13 @@ SWITCH_STANDARD_APP(valet_parking_function) switch_channel_t *channel = switch_core_session_get_channel(session); switch_event_t *event; char dtmf_buf[128] = ""; - int is_auto = 0; + int is_auto = 0, play_announce = 1; + const char *var; + + + if ((var = switch_channel_get_variable(channel, "valet_announce_slot"))) { + play_announce = switch_true(var); + } if (!zstr(data) && (lbuf = switch_core_session_strdup(session, data)) && (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 2) { @@ -254,7 +260,9 @@ SWITCH_STANDARD_APP(valet_parking_function) switch_core_session_t *b_session; if ((b_session = switch_core_session_locate(uuid))) { - switch_ivr_phrase_macro(session, "valet_announce_ext", tmp, NULL, NULL); + if (play_announce) { + switch_ivr_phrase_macro(session, "valet_announce_ext", tmp, NULL, NULL); + } switch_ivr_session_transfer(b_session, dest, "inline", NULL); switch_mutex_unlock(lot->mutex); switch_core_session_rwunlock(b_session); @@ -263,7 +271,9 @@ SWITCH_STANDARD_APP(valet_parking_function) } } - switch_ivr_phrase_macro(session, "valet_announce_ext", tmp, NULL, NULL); + if (play_announce) { + switch_ivr_phrase_macro(session, "valet_announce_ext", tmp, NULL, NULL); + } } diff --git a/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c b/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c index d5bac5f7f4..8698e4a02c 100644 --- a/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c +++ b/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c @@ -3155,15 +3155,19 @@ static switch_status_t recog_asr_disable_all_grammars(switch_asr_handle_t *ah) static switch_status_t recog_asr_close(switch_asr_handle_t *ah, switch_asr_flag_t *flags) { speech_channel_t *schannel = (speech_channel_t *) ah->private_info; - recognizer_data_t *r = (recognizer_data_t *) schannel->data; - speech_channel_stop(schannel); - speech_channel_destroy(schannel); - switch_core_hash_destroy(&r->grammars); - switch_core_hash_destroy(&r->enabled_grammars); - if (r->dtmf_generator) { - mpf_dtmf_generator_destroy(r->dtmf_generator); - } + recognizer_data_t *r = NULL; + /* close if not already closed */ + if (schannel != NULL && !switch_test_flag(ah, SWITCH_ASR_FLAG_CLOSED)) { + r = (recognizer_data_t *) schannel->data; + speech_channel_stop(schannel); + speech_channel_destroy(schannel); + switch_core_hash_destroy(&r->grammars); + switch_core_hash_destroy(&r->enabled_grammars); + if (r->dtmf_generator) { + mpf_dtmf_generator_destroy(r->dtmf_generator); + } + } /* this lets FreeSWITCH's speech_thread know the handle is closed */ switch_set_flag(ah, SWITCH_ASR_FLAG_CLOSED); diff --git a/src/mod/endpoints/mod_dingaling/mod_dingaling.c b/src/mod/endpoints/mod_dingaling/mod_dingaling.c index 9fb1f39e11..7cd9e5618b 100644 --- a/src/mod/endpoints/mod_dingaling/mod_dingaling.c +++ b/src/mod/endpoints/mod_dingaling/mod_dingaling.c @@ -77,6 +77,7 @@ typedef enum { TFLAG_TERM = (1 << 20), TFLAG_TRANSPORT_ACCEPT = (1 << 21), TFLAG_READY = (1 << 22), + TFLAG_NAT_MAP = (1 << 22) } TFLAGS; typedef enum { @@ -158,6 +159,7 @@ struct private_object { ldl_session_t *dlsession; char *remote_ip; switch_port_t local_port; + switch_port_t adv_local_port; switch_port_t remote_port; char local_user[17]; char local_pass[17]; @@ -596,9 +598,9 @@ static void ipchanged_event_handler(switch_event_t *event) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "EVENT_TRAP: IP change detected\n"); - if (cond && !strcmp(cond, "network-address-change")) { - const char *old_ip4 = switch_event_get_header_nil(event, "network-address-previous-v4"); - const char *new_ip4 = switch_event_get_header_nil(event, "network-address-change-v4"); + if (cond && !strcmp(cond, "network-external-address-change")) { + const char *old_ip4 = switch_event_get_header_nil(event, "network-external-address-previous-v4"); + const char *new_ip4 = switch_event_get_header_nil(event, "network-external-address-change-v4"); switch_hash_index_t *hi; void *val; char *tmp; @@ -886,11 +888,22 @@ static int activate_rtp(struct private_object *tech_pvt) if (globals.auto_nat && tech_pvt->profile->local_network && !switch_check_network_list_ip(tech_pvt->remote_ip, tech_pvt->profile->local_network)) { switch_port_t external_port = 0; switch_nat_add_mapping((switch_port_t) tech_pvt->local_port, SWITCH_NAT_UDP, &external_port, SWITCH_FALSE); - tech_pvt->local_port = external_port; + + if (external_port) { + tech_pvt->adv_local_port = external_port; + switch_set_flag(tech_pvt, TFLAG_NAT_MAP); + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "NAT mapping returned 0. Run freeswitch with -nonat since it's not working right.\n"); + } } - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "SETUP RTP %s:%d -> %s:%d\n", tech_pvt->profile->ip, - tech_pvt->local_port, tech_pvt->remote_ip, tech_pvt->remote_port); + if (tech_pvt->adv_local_port != tech_pvt->local_port) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "SETUP RTP %s:%d(%d) -> %s:%d\n", tech_pvt->profile->ip, + tech_pvt->local_port, tech_pvt->adv_local_port, tech_pvt->remote_ip, tech_pvt->remote_port); + } else { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "SETUP RTP %s:%d -> %s:%d\n", tech_pvt->profile->ip, + tech_pvt->local_port, tech_pvt->remote_ip, tech_pvt->remote_port); + } flags = SWITCH_RTP_FLAG_DATAWAIT | SWITCH_RTP_FLAG_GOOGLEHACK | SWITCH_RTP_FLAG_AUTOADJ | SWITCH_RTP_FLAG_RAW_WRITE | SWITCH_RTP_FLAG_AUTO_CNG; @@ -964,7 +977,7 @@ static int do_candidates(struct private_object *tech_pvt, int force) } - cand[0].port = tech_pvt->local_port; + cand[0].port = tech_pvt->adv_local_port; cand[0].address = advip; if (!strncasecmp(advip, "stun:", 5)) { @@ -1253,9 +1266,9 @@ static switch_status_t channel_on_destroy(switch_core_session_t *session) tech_pvt->rtp_session = NULL; } - if (globals.auto_nat && tech_pvt->profile->local_network && tech_pvt->remote_ip && tech_pvt->profile->local_network && - !switch_check_network_list_ip(tech_pvt->remote_ip, tech_pvt->profile->local_network)) { - switch_nat_del_mapping((switch_port_t) tech_pvt->local_port, SWITCH_NAT_UDP); + if (switch_test_flag(tech_pvt, TFLAG_NAT_MAP)) { + switch_nat_del_mapping((switch_port_t) tech_pvt->adv_local_port, SWITCH_NAT_UDP); + switch_clear_flag(tech_pvt, TFLAG_NAT_MAP); } if (switch_core_codec_ready(&tech_pvt->read_codec)) { @@ -1751,6 +1764,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi terminate_session(new_session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; } + tech_pvt->adv_local_port = tech_pvt->local_port; tech_pvt->recip = switch_core_session_strdup(*new_session, full_id); if (dnis) { tech_pvt->dnis = switch_core_session_strdup(*new_session, dnis); @@ -2992,6 +3006,7 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi status = LDL_STATUS_FALSE; goto done; } + tech_pvt->adv_local_port = tech_pvt->local_port; switch_set_flag_locked(tech_pvt, TFLAG_ANSWER); tech_pvt->recip = switch_core_session_strdup(session, from); if (!(exten = ldl_session_get_value(dlsession, "dnis"))) { diff --git a/src/mod/endpoints/mod_skinny/mod_skinny.c b/src/mod/endpoints/mod_skinny/mod_skinny.c index 5320ca52d1..b05806b8d9 100644 --- a/src/mod/endpoints/mod_skinny/mod_skinny.c +++ b/src/mod/endpoints/mod_skinny/mod_skinny.c @@ -651,7 +651,7 @@ int channel_on_routing_callback(void *pArg, int argc, char **argv, char **column } else { send_set_lamp(listener, SKINNY_BUTTON_LINE, line_instance, SKINNY_LAMP_ON); skinny_line_set_state(listener, line_instance, helper->tech_pvt->call_id, SKINNY_IN_USE_REMOTELY); - send_select_soft_keys(listener, line_instance, helper->tech_pvt->call_id, 10, 0xffff); + send_select_soft_keys(listener, line_instance, helper->tech_pvt->call_id, SKINNY_KEY_SET_IN_USE_HINT, 0xffff); send_display_prompt_status(listener, 0, SKINNY_DISP_IN_USE_REMOTE, line_instance, helper->tech_pvt->call_id); skinny_session_send_call_info(helper->tech_pvt->session, listener, line_instance); @@ -1243,6 +1243,21 @@ static void walk_listeners(skinny_listener_callback_func_t callback, void *pvt) switch_mutex_unlock(globals.mutex); } +static int flush_listener_callback(void *pArg, int argc, char **argv, char **columnNames) +{ + char *profile_name = argv[0]; + char *value = argv[1]; + char *domain_name = argv[2]; + char *device_name = argv[3]; + char *device_instance = argv[4]; + + char *token = switch_mprintf("skinny/%q/%q/%q:%q", profile_name, value, device_name, device_instance); + switch_core_del_registration(value, domain_name, token); + switch_safe_free(token); + + return 0; +} + static void flush_listener(listener_t *listener) { @@ -1250,6 +1265,18 @@ static void flush_listener(listener_t *listener) skinny_profile_t *profile = listener->profile; char *sql; + if ((sql = switch_mprintf( + "SELECT '%q', value, '%q', '%q', '%d' " + "FROM skinny_lines " + "WHERE device_name='%s' AND device_instance=%d " + "ORDER BY position", + profile->name, profile->domain, listener->device_name, listener->device_instance, + listener->device_name, listener->device_instance + ))) { + skinny_execute_sql_callback(profile, profile->sql_mutex, sql, flush_listener_callback, NULL); + switch_safe_free(sql); + } + if ((sql = switch_mprintf( "DELETE FROM skinny_devices " "WHERE name='%s' and instance=%d", @@ -1488,6 +1515,8 @@ static void *SWITCH_THREAD_FUNC skinny_profile_run(switch_thread_t *thread, void listener_t *listener; switch_memory_pool_t *tmp_pool = NULL, *listener_pool = NULL; uint32_t errs = 0; + switch_sockaddr_t *local_sa = NULL; + switch_sockaddr_t *remote_sa =NULL; if (switch_core_new_memory_pool(&tmp_pool) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "OH OH no pool\n"); @@ -1496,8 +1525,9 @@ static void *SWITCH_THREAD_FUNC skinny_profile_run(switch_thread_t *thread, void new_socket: while(globals.running) { + char *listening_ip = NULL; switch_clear_flag_locked(profile, PFLAG_RESPAWN); - rv = switch_sockaddr_info_get(&sa, profile->ip, SWITCH_INET, profile->port, 0, tmp_pool); + rv = switch_sockaddr_info_get(&sa, profile->ip, SWITCH_UNSPEC, profile->port, 0, tmp_pool); if (rv) goto fail; rv = switch_socket_create(&profile->sock, switch_sockaddr_get_family(sa), SOCK_STREAM, SWITCH_PROTO_TCP, tmp_pool); @@ -1512,6 +1542,10 @@ new_socket: rv = switch_socket_listen(profile->sock, 5); if (rv) goto sock_fail; + switch_sockaddr_ip_get(&listening_ip, sa); + if (!profile->ip || strcmp(listening_ip, profile->ip)) { + profile->ip = switch_core_strdup(profile->pool, listening_ip); + } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Socket up listening on %s:%u\n", profile->ip, profile->port); break; @@ -1566,9 +1600,14 @@ new_socket: switch_mutex_init(&listener->flag_mutex, SWITCH_MUTEX_NESTED, listener->pool); - switch_socket_addr_get(&listener->sa, SWITCH_TRUE, listener->sock); - switch_get_addr(listener->remote_ip, sizeof(listener->remote_ip), listener->sa); - listener->remote_port = switch_sockaddr_get_port(listener->sa); + switch_socket_addr_get(&remote_sa, SWITCH_TRUE, listener->sock); + switch_get_addr(listener->remote_ip, sizeof(listener->remote_ip), remote_sa); + listener->remote_port = switch_sockaddr_get_port(remote_sa); + + switch_socket_addr_get(&local_sa, SWITCH_FALSE, listener->sock); + switch_get_addr(listener->local_ip, sizeof(listener->local_ip), local_sa); + listener->local_port = switch_sockaddr_get_port(local_sa); + launch_listener_thread(listener); } @@ -1636,7 +1675,7 @@ switch_status_t skinny_profile_set(skinny_profile_t *profile, const char *var, c profile->domain = switch_core_strdup(profile->pool, val); } else if (!strcasecmp(var, "ip")) { if (!profile->ip || strcmp(val, profile->ip)) { - profile->ip = switch_core_strdup(profile->pool, val); + profile->ip = switch_core_strdup(profile->pool, zstr(val) ? NULL : val); switch_set_flag_locked(profile, PFLAG_SHOULD_RESPAWN); } } else if (!strcasecmp(var, "port")) { @@ -1784,6 +1823,9 @@ static switch_status_t load_skinny_config(void) size_t string_len = strlen(val); size_t string_pos, start = 0; int field_no = 0; + if (zstr(val)) { + continue; + } if (soft_key_set_id > 15) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "soft-key-set name '%s' is greater than 15 in soft-key-set-set '%s' in profile %s.\n", diff --git a/src/mod/endpoints/mod_skinny/mod_skinny.h b/src/mod/endpoints/mod_skinny/mod_skinny.h index 20d68faba5..eb7e45ebc0 100644 --- a/src/mod/endpoints/mod_skinny/mod_skinny.h +++ b/src/mod/endpoints/mod_skinny/mod_skinny.h @@ -132,25 +132,25 @@ typedef enum { #define SKINNY_MAX_LINES 42 struct listener { - skinny_profile_t *profile; - char device_name[16]; - uint32_t device_instance; - uint32_t device_type; - + skinny_profile_t *profile; + char device_name[16]; + uint32_t device_instance; + uint32_t device_type; + char firmware_version[16]; char *soft_key_set_set; - switch_socket_t *sock; - switch_memory_pool_t *pool; - switch_thread_rwlock_t *rwlock; - switch_sockaddr_t *sa; - char remote_ip[50]; - switch_mutex_t *flag_mutex; - uint32_t flags; - switch_port_t remote_port; - uint32_t id; - time_t expire_time; - struct listener *next; + switch_socket_t *sock; + switch_memory_pool_t *pool; + switch_thread_rwlock_t *rwlock; + char remote_ip[50]; + switch_port_t remote_port; + char local_ip[50]; + switch_port_t local_port; + switch_mutex_t *flag_mutex; + uint32_t flags; + time_t expire_time; + struct listener *next; }; typedef struct listener listener_t; diff --git a/src/mod/endpoints/mod_skinny/skinny_protocol.c b/src/mod/endpoints/mod_skinny/skinny_protocol.c index 743514d98c..4c09c70176 100644 --- a/src/mod/endpoints/mod_skinny/skinny_protocol.c +++ b/src/mod/endpoints/mod_skinny/skinny_protocol.c @@ -43,10 +43,10 @@ char* skinny_codec2string(enum skinny_codecs skinnycodec) switch (skinnycodec) { case SKINNY_CODEC_ALAW_64K: case SKINNY_CODEC_ALAW_56K: - return "ALAW"; + return "PCMA"; case SKINNY_CODEC_ULAW_64K: case SKINNY_CODEC_ULAW_56K: - return "ULAW"; + return "PCMU"; case SKINNY_CODEC_G722_64K: case SKINNY_CODEC_G722_56K: case SKINNY_CODEC_G722_48K: diff --git a/src/mod/endpoints/mod_skinny/skinny_protocol.h b/src/mod/endpoints/mod_skinny/skinny_protocol.h index 1a26558ffc..8f8911f2a7 100644 --- a/src/mod/endpoints/mod_skinny/skinny_protocol.h +++ b/src/mod/endpoints/mod_skinny/skinny_protocol.h @@ -97,6 +97,12 @@ struct PACKED on_hook_message { uint32_t call_id; }; +/* ForwardStatReqMessage */ +#define FORWARD_STAT_REQ_MESSAGE 0x0009 +struct PACKED forward_stat_req_message { + uint32_t line_instance; +}; + /* SpeedDialStatReqMessage */ #define SPEED_DIAL_STAT_REQ_MESSAGE 0x000A struct PACKED speed_dial_stat_req_message { @@ -125,7 +131,7 @@ struct PACKED line_stat_req_message { #define CAPABILITIES_RES_MESSAGE 0x0010 struct PACKED station_capabilities { uint32_t codec; - uint16_t frames; + uint16_t max_frames_per_packet; char reserved[10]; }; @@ -328,6 +334,19 @@ struct PACKED call_info_message { uint32_t party_pi_restriction_bits; }; +/* ForwardStatMessage */ +#define FORWARD_STAT_MESSAGE 0x0090 +struct PACKED forward_stat_message { + uint32_t active_forward; + uint32_t line_instance; + uint32_t forward_all_active; + char forward_all_number[24]; + uint32_t forward_busy_active; + char forward_busy_number[24]; + uint32_t forward_noanswer_active; + char forward_noanswer_number[24]; +}; + /* SpeedDialStatMessage */ #define SPEED_DIAL_STAT_RES_MESSAGE 0x0091 struct PACKED speed_dial_stat_res_message { @@ -566,76 +585,78 @@ struct PACKED service_url_stat_res_message { union skinny_data { /* no data for KEEP_ALIVE_MESSAGE */ - struct register_message reg; - struct port_message port; - struct keypad_button_message keypad_button; - struct enbloc_call_message enbloc_call; - struct stimulus_message stimulus; - struct off_hook_message off_hook; - struct on_hook_message on_hook; - struct speed_dial_stat_req_message speed_dial_req; - struct line_stat_req_message line_req; - /* no data for CONFIG_STAT_REQ_MESSAGE */ - /* no data for TIME_DATE_REQ_MESSAGE */ - /* no data for BUTTON_TEMPLATE_REQ_MESSAGE */ - /* no data for VERSION_REQ_MESSAGE */ - struct capabilities_res_message cap_res; - struct alarm_message alarm; - struct open_receive_channel_ack_message open_receive_channel_ack; - /* no data for SOFT_KEY_SET_REQ_MESSAGE */ - struct soft_key_event_message soft_key_event; - /* no data for UNREGISTER_MESSAGE */ - /* no data for SOFT_KEY_TEMPLATE_REQ_MESSAGE */ - struct headset_status_message headset_status; - struct register_available_lines_message reg_lines; - /* see field "data" for DEVICE_TO_USER_DATA_MESSAGE */ - /* see field "data" for DEVICE_TO_USER_DATA_RESPONSE_MESSAGE */ - struct service_url_stat_req_message service_url_req; - struct feature_stat_req_message feature_req; - /* see field "extended_data" for DEVICE_TO_USER_DATA_VERSION1_MESSAGE */ - /* see field "extended_data" for DEVICE_TO_USER_DATA_RESPONSE_VERSION1_MESSAGE */ - struct register_ack_message reg_ack; - struct start_tone_message start_tone; - struct stop_tone_message stop_tone; - struct set_ringer_message ringer; - struct set_lamp_message lamp; - struct set_speaker_mode_message speaker_mode; - struct start_media_transmission_message start_media; - struct stop_media_transmission_message stop_media; - struct call_info_message call_info; - struct speed_dial_stat_res_message speed_dial_res; - struct line_stat_res_message line_res; - struct config_stat_res_message config_res; - struct define_time_date_message define_time_date; - struct button_template_message button_template; - struct version_message version; - /* no data for CAPABILITIES_REQ_MESSAGE */ - struct register_reject_message reg_rej; - struct reset_message reset; - /* no data for KEEP_ALIVE_ACK_MESSAGE */ - struct open_receive_channel_message open_receive_channel; - struct close_receive_channel_message close_receive_channel; - struct soft_key_template_res_message soft_key_template; - struct soft_key_set_res_message soft_key_set; - struct select_soft_keys_message select_soft_keys; - struct call_state_message call_state; - struct display_prompt_status_message display_prompt_status; - struct clear_prompt_status_message clear_prompt_status; - struct activate_call_plane_message activate_call_plane; - struct unregister_ack_message unregister_ack; - struct back_space_req_message back_space_req; - struct dialed_number_message dialed_number; - /* see field "data" for USER_TO_DEVICE_DATA_MESSAGE */ - struct feature_stat_res_message feature_res; - struct display_pri_notify_message display_pri_notify; - struct service_url_stat_res_message service_url_res; - /* see field "extended_data" for USER_TO_DEVICE_DATA_VERSION1_MESSAGE */ + struct register_message reg; + struct port_message port; + struct keypad_button_message keypad_button; + struct enbloc_call_message enbloc_call; + struct stimulus_message stimulus; + struct off_hook_message off_hook; + struct on_hook_message on_hook; + struct forward_stat_req_message forward_stat_req; + struct speed_dial_stat_req_message speed_dial_req; + struct line_stat_req_message line_req; + /* no data for CONFIG_STAT_REQ_MESSAGE */ + /* no data for TIME_DATE_REQ_MESSAGE */ + /* no data for BUTTON_TEMPLATE_REQ_MESSAGE */ + /* no data for VERSION_REQ_MESSAGE */ + struct capabilities_res_message cap_res; + struct alarm_message alarm; + struct open_receive_channel_ack_message open_receive_channel_ack; + /* no data for SOFT_KEY_SET_REQ_MESSAGE */ + struct soft_key_event_message soft_key_event; + /* no data for UNREGISTER_MESSAGE */ + /* no data for SOFT_KEY_TEMPLATE_REQ_MESSAGE */ + struct headset_status_message headset_status; + struct register_available_lines_message reg_lines; + /* see field "data" for DEVICE_TO_USER_DATA_MESSAGE */ + /* see field "data" for DEVICE_TO_USER_DATA_RESPONSE_MESSAGE */ + struct service_url_stat_req_message service_url_req; + struct feature_stat_req_message feature_req; + /* see field "extended_data" for DEVICE_TO_USER_DATA_VERSION1_MESSAGE */ + /* see field "extended_data" for DEVICE_TO_USER_DATA_RESPONSE_VERSION1_MESSAGE */ + struct register_ack_message reg_ack; + struct start_tone_message start_tone; + struct stop_tone_message stop_tone; + struct set_ringer_message ringer; + struct set_lamp_message lamp; + struct set_speaker_mode_message speaker_mode; + struct start_media_transmission_message start_media; + struct stop_media_transmission_message stop_media; + struct call_info_message call_info; + struct forward_stat_message forward_stat; + struct speed_dial_stat_res_message speed_dial_res; + struct line_stat_res_message line_res; + struct config_stat_res_message config_res; + struct define_time_date_message define_time_date; + struct button_template_message button_template; + struct version_message version; + /* no data for CAPABILITIES_REQ_MESSAGE */ + struct register_reject_message reg_rej; + struct reset_message reset; + /* no data for KEEP_ALIVE_ACK_MESSAGE */ + struct open_receive_channel_message open_receive_channel; + struct close_receive_channel_message close_receive_channel; + struct soft_key_template_res_message soft_key_template; + struct soft_key_set_res_message soft_key_set; + struct select_soft_keys_message select_soft_keys; + struct call_state_message call_state; + struct display_prompt_status_message display_prompt_status; + struct clear_prompt_status_message clear_prompt_status; + struct activate_call_plane_message activate_call_plane; + struct unregister_ack_message unregister_ack; + struct back_space_req_message back_space_req; + struct dialed_number_message dialed_number; + /* see field "data" for USER_TO_DEVICE_DATA_MESSAGE */ + struct feature_stat_res_message feature_res; + struct display_pri_notify_message display_pri_notify; + struct service_url_stat_res_message service_url_res; + /* see field "extended_data" for USER_TO_DEVICE_DATA_VERSION1_MESSAGE */ struct data_message data; struct extended_data_message extended_data; - uint16_t as_uint16; - char as_char[1]; + uint16_t as_uint16; + char as_char[1]; }; /* diff --git a/src/mod/endpoints/mod_skinny/skinny_server.c b/src/mod/endpoints/mod_skinny/skinny_server.c index e7c761dfca..dac75facd7 100644 --- a/src/mod/endpoints/mod_skinny/skinny_server.c +++ b/src/mod/endpoints/mod_skinny/skinny_server.c @@ -555,6 +555,7 @@ int skinny_ring_lines_callback(void *pArg, int argc, char **argv, char **columnN skinny_session_send_call_info(helper->tech_pvt->session, listener, line_instance); send_set_lamp(listener, SKINNY_BUTTON_LINE, line_instance, SKINNY_LAMP_BLINK); send_set_ringer(listener, SKINNY_RING_INSIDE, SKINNY_RING_FOREVER, 0, helper->tech_pvt->call_id); + switch_channel_mark_ring_ready(channel); } return 0; } @@ -1006,6 +1007,10 @@ switch_status_t skinny_handle_register(listener_t *listener, skinny_message_t *r } if ((xbuttons = switch_xml_child(xskinny, "buttons"))) { uint32_t line_instance = 1; + char *network_ip = inet_ntoa(request->data.reg.ip); + int network_port = 0; + char network_port_c[6]; + snprintf(network_port_c, sizeof(network_port_c), "%d", network_port); for (xbutton = switch_xml_child(xbuttons, "button"); xbutton; xbutton = xbutton->next) { uint32_t position = atoi(switch_xml_attr_soft(xbutton, "position")); uint32_t type = skinny_str2button(switch_xml_attr_soft(xbutton, "type")); @@ -1031,8 +1036,14 @@ switch_status_t skinny_handle_register(listener_t *listener, skinny_message_t *r label, value, caller_name, ring_on_idle, ring_on_active, busy_trigger, forward_all, forward_busy, forward_noanswer, noanswer_duration))) { + char *token, *url; skinny_execute_sql(profile, sql, profile->sql_mutex); switch_safe_free(sql); + token = switch_mprintf("skinny/%q/%q/%q:%d", profile->name, value, request->data.reg.device_name, request->data.reg.instance); + url = switch_mprintf("skinny/%q/%q", profile->name, value); + switch_core_add_registration(value, profile->domain, token, url, 0, network_ip, network_port_c, "tcp"); + switch_safe_free(token); + switch_safe_free(url); } if (line_instance == 1) { switch_event_t *message_query_event = NULL; @@ -1318,6 +1329,22 @@ switch_status_t skinny_handle_on_hook_message(listener_t *listener, skinny_messa return status; } +switch_status_t skinny_handle_forward_stat_req_message(listener_t *listener, skinny_message_t *request) +{ + skinny_message_t *message; + + skinny_check_data_length(request, sizeof(request->data.forward_stat_req)); + + message = switch_core_alloc(listener->pool, 12+sizeof(message->data.forward_stat)); + message->type = FORWARD_STAT_MESSAGE; + message->length = 4 + sizeof(message->data.forward_stat); + + message->data.forward_stat.line_instance = request->data.forward_stat_req.line_instance; + + skinny_send_reply(listener, message); + + return SWITCH_STATUS_SUCCESS; +} switch_status_t skinny_handle_speed_dial_stat_request(listener_t *listener, skinny_message_t *request) { @@ -1649,12 +1676,12 @@ switch_status_t skinny_handle_open_receive_channel_ack_message(listener_t *liste goto end; } + tech_pvt->local_sdp_audio_ip = listener->local_ip; /* Request a local port from the core's allocator */ - if (!(tech_pvt->local_sdp_audio_port = switch_rtp_request_port(listener->profile->ip))) { + if (!(tech_pvt->local_sdp_audio_port = switch_rtp_request_port(tech_pvt->local_sdp_audio_ip))) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_CRIT, "No RTP ports available!\n"); return SWITCH_STATUS_FALSE; } - tech_pvt->local_sdp_audio_ip = switch_core_strdup(switch_core_session_get_pool(session), listener->profile->ip); tech_pvt->remote_sdp_audio_ip = inet_ntoa(request->data.open_receive_channel_ack.ip); tech_pvt->remote_sdp_audio_port = request->data.open_receive_channel_ack.port; @@ -2035,6 +2062,8 @@ switch_status_t skinny_handle_request(listener_t *listener, skinny_message_t *re return skinny_handle_off_hook_message(listener, request); case ON_HOOK_MESSAGE: return skinny_handle_on_hook_message(listener, request); + case FORWARD_STAT_REQ_MESSAGE: + return skinny_handle_forward_stat_req_message(listener, request); case SPEED_DIAL_STAT_REQ_MESSAGE: return skinny_handle_speed_dial_stat_request(listener, request); case LINE_STAT_REQ_MESSAGE: diff --git a/src/mod/endpoints/mod_skinny/skinny_tables.c b/src/mod/endpoints/mod_skinny/skinny_tables.c index 466a70538d..e8e56568b3 100644 --- a/src/mod/endpoints/mod_skinny/skinny_tables.c +++ b/src/mod/endpoints/mod_skinny/skinny_tables.c @@ -35,73 +35,75 @@ /* Translation tables */ struct skinny_table SKINNY_MESSAGE_TYPES[] = { - {"KeepAliveMessage", KEEP_ALIVE_MESSAGE}, - {"RegisterMessage", REGISTER_MESSAGE}, - {"PortMessage", PORT_MESSAGE}, - {"KeypadButtonMessage", KEYPAD_BUTTON_MESSAGE}, - {"EnblocCallMessage", ENBLOC_CALL_MESSAGE}, - {"StimulusMessage", STIMULUS_MESSAGE}, - {"OffHookMessage", OFF_HOOK_MESSAGE}, - {"OnHookMessage", ON_HOOK_MESSAGE}, - {"SpeedDialStatReqMessage", SPEED_DIAL_STAT_REQ_MESSAGE}, - {"LineStatReqMessage", LINE_STAT_REQ_MESSAGE}, - {"ConfigStatReqMessage", CONFIG_STAT_REQ_MESSAGE}, - {"TimeDateReqMessage", TIME_DATE_REQ_MESSAGE}, - {"ButtonTemplateReqMessage", BUTTON_TEMPLATE_REQ_MESSAGE}, - {"VersionReqMessage", VERSION_REQ_MESSAGE}, - {"CapabilitiesReqMessage", CAPABILITIES_RES_MESSAGE}, - {"AlarmMessage", ALARM_MESSAGE}, - {"OpenReceiveChannelAckMessage", OPEN_RECEIVE_CHANNEL_ACK_MESSAGE}, - {"SoftKeySetReqMessage", SOFT_KEY_SET_REQ_MESSAGE}, - {"SoftKeyEventMessage", SOFT_KEY_EVENT_MESSAGE}, - {"UnregisterMessage", UNREGISTER_MESSAGE}, - {"SoftKeyTemplateReqMessage", SOFT_KEY_TEMPLATE_REQ_MESSAGE}, - {"HeadsetStatusMessage", HEADSET_STATUS_MESSAGE}, - {"RegisterAvailableLinesMessage", REGISTER_AVAILABLE_LINES_MESSAGE}, - {"DeviceToUserDataMessage", DEVICE_TO_USER_DATA_MESSAGE}, - {"DeviceToUserDataResponseMessage", DEVICE_TO_USER_DATA_RESPONSE_MESSAGE}, - {"ServiceUrlStatReqMessage", SERVICE_URL_STAT_REQ_MESSAGE}, - {"FeatureStatReqMessage", FEATURE_STAT_REQ_MESSAGE}, - {"DeviceToUserDataVersion1Message", DEVICE_TO_USER_DATA_VERSION1_MESSAGE}, - {"DeviceToUserDataResponseVersion1Message", DEVICE_TO_USER_DATA_RESPONSE_VERSION1_MESSAGE}, - {"RegisterAckMessage", REGISTER_ACK_MESSAGE}, - {"StartToneMessage", START_TONE_MESSAGE}, - {"StopToneMessage", STOP_TONE_MESSAGE}, - {"SetRingerMessage", SET_RINGER_MESSAGE}, - {"SetLampMessage", SET_LAMP_MESSAGE}, - {"SetSpeakerModeMessage", SET_SPEAKER_MODE_MESSAGE}, - {"StartMediaTransmissionMessage", START_MEDIA_TRANSMISSION_MESSAGE}, - {"StopMediaTransmissionMessage", STOP_MEDIA_TRANSMISSION_MESSAGE}, - {"CallInfoMessage", CALL_INFO_MESSAGE}, - {"SpeedDialStatResMessage", SPEED_DIAL_STAT_RES_MESSAGE}, - {"LineStatResMessage", LINE_STAT_RES_MESSAGE}, - {"ConfigStatResMessage", CONFIG_STAT_RES_MESSAGE}, - {"DefineTimeDateMessage", DEFINE_TIME_DATE_MESSAGE}, - {"ButtonTemplateResMessage", BUTTON_TEMPLATE_RES_MESSAGE}, - {"VersionMessage", VERSION_MESSAGE}, - {"CapabilitiesReqMessage", CAPABILITIES_REQ_MESSAGE}, - {"RegisterRejectMessage", REGISTER_REJECT_MESSAGE}, - {"ResetMessage", RESET_MESSAGE}, - {"KeepAliveAckMessage", KEEP_ALIVE_ACK_MESSAGE}, - {"OpenReceiveChannelMessage", OPEN_RECEIVE_CHANNEL_MESSAGE}, - {"CloseReceiveChannelMessage", CLOSE_RECEIVE_CHANNEL_MESSAGE}, - {"SoftKeyTemplateResMessage", SOFT_KEY_TEMPLATE_RES_MESSAGE}, - {"SoftKeySetResMessage", SOFT_KEY_SET_RES_MESSAGE}, - {"SelectSoftKeysMessage", SELECT_SOFT_KEYS_MESSAGE}, - {"CallStateMessage", CALL_STATE_MESSAGE}, - {"DisplayPromptStatusMessage", DISPLAY_PROMPT_STATUS_MESSAGE}, - {"ClearPromptStatusMessage", CLEAR_PROMPT_STATUS_MESSAGE}, - {"ActivateCallPlaneMessage", ACTIVATE_CALL_PLANE_MESSAGE}, - {"UnregisterAckMessage", UNREGISTER_ACK_MESSAGE}, - {"BackSpaceReqMessage", BACK_SPACE_REQ_MESSAGE}, - {"DialedNumberMessage", DIALED_NUMBER_MESSAGE}, - {"UserToDeviceDataMessage", USER_TO_DEVICE_DATA_MESSAGE}, - {"FeatureResMessage", FEATURE_STAT_RES_MESSAGE}, - {"DisplayPriNotifyMessage", DISPLAY_PRI_NOTIFY_MESSAGE}, - {"ServiceUrlStatMessage", SERVICE_URL_STAT_RES_MESSAGE}, - {"UserToDeviceDataVersion1Message", USER_TO_DEVICE_DATA_VERSION1_MESSAGE}, - {"XMLAlarmMessage", XML_ALARM_MESSAGE}, - {NULL, 0} + {"KeepAliveMessage", KEEP_ALIVE_MESSAGE}, + {"RegisterMessage", REGISTER_MESSAGE}, + {"PortMessage", PORT_MESSAGE}, + {"KeypadButtonMessage", KEYPAD_BUTTON_MESSAGE}, + {"EnblocCallMessage", ENBLOC_CALL_MESSAGE}, + {"StimulusMessage", STIMULUS_MESSAGE}, + {"OffHookMessage", OFF_HOOK_MESSAGE}, + {"OnHookMessage", ON_HOOK_MESSAGE}, + {"ForwardStatReqMessage", FORWARD_STAT_REQ_MESSAGE}, + {"SpeedDialStatReqMessage", SPEED_DIAL_STAT_REQ_MESSAGE}, + {"LineStatReqMessage", LINE_STAT_REQ_MESSAGE}, + {"ConfigStatReqMessage", CONFIG_STAT_REQ_MESSAGE}, + {"TimeDateReqMessage", TIME_DATE_REQ_MESSAGE}, + {"ButtonTemplateReqMessage", BUTTON_TEMPLATE_REQ_MESSAGE}, + {"VersionReqMessage", VERSION_REQ_MESSAGE}, + {"CapabilitiesReqMessage", CAPABILITIES_RES_MESSAGE}, + {"AlarmMessage", ALARM_MESSAGE}, + {"OpenReceiveChannelAckMessage", OPEN_RECEIVE_CHANNEL_ACK_MESSAGE}, + {"SoftKeySetReqMessage", SOFT_KEY_SET_REQ_MESSAGE}, + {"SoftKeyEventMessage", SOFT_KEY_EVENT_MESSAGE}, + {"UnregisterMessage", UNREGISTER_MESSAGE}, + {"SoftKeyTemplateReqMessage", SOFT_KEY_TEMPLATE_REQ_MESSAGE}, + {"HeadsetStatusMessage", HEADSET_STATUS_MESSAGE}, + {"RegisterAvailableLinesMessage", REGISTER_AVAILABLE_LINES_MESSAGE}, + {"DeviceToUserDataMessage", DEVICE_TO_USER_DATA_MESSAGE}, + {"DeviceToUserDataResponseMessage", DEVICE_TO_USER_DATA_RESPONSE_MESSAGE}, + {"ServiceUrlStatReqMessage", SERVICE_URL_STAT_REQ_MESSAGE}, + {"FeatureStatReqMessage", FEATURE_STAT_REQ_MESSAGE}, + {"DeviceToUserDataVersion1Message", DEVICE_TO_USER_DATA_VERSION1_MESSAGE}, + {"DeviceToUserDataResponseVersion1Message", DEVICE_TO_USER_DATA_RESPONSE_VERSION1_MESSAGE}, + {"RegisterAckMessage", REGISTER_ACK_MESSAGE}, + {"StartToneMessage", START_TONE_MESSAGE}, + {"StopToneMessage", STOP_TONE_MESSAGE}, + {"SetRingerMessage", SET_RINGER_MESSAGE}, + {"SetLampMessage", SET_LAMP_MESSAGE}, + {"SetSpeakerModeMessage", SET_SPEAKER_MODE_MESSAGE}, + {"StartMediaTransmissionMessage", START_MEDIA_TRANSMISSION_MESSAGE}, + {"StopMediaTransmissionMessage", STOP_MEDIA_TRANSMISSION_MESSAGE}, + {"CallInfoMessage", CALL_INFO_MESSAGE}, + {"ForwardStatMessage", FORWARD_STAT_MESSAGE}, + {"SpeedDialStatResMessage", SPEED_DIAL_STAT_RES_MESSAGE}, + {"LineStatResMessage", LINE_STAT_RES_MESSAGE}, + {"ConfigStatResMessage", CONFIG_STAT_RES_MESSAGE}, + {"DefineTimeDateMessage", DEFINE_TIME_DATE_MESSAGE}, + {"ButtonTemplateResMessage", BUTTON_TEMPLATE_RES_MESSAGE}, + {"VersionMessage", VERSION_MESSAGE}, + {"CapabilitiesReqMessage", CAPABILITIES_REQ_MESSAGE}, + {"RegisterRejectMessage", REGISTER_REJECT_MESSAGE}, + {"ResetMessage", RESET_MESSAGE}, + {"KeepAliveAckMessage", KEEP_ALIVE_ACK_MESSAGE}, + {"OpenReceiveChannelMessage", OPEN_RECEIVE_CHANNEL_MESSAGE}, + {"CloseReceiveChannelMessage", CLOSE_RECEIVE_CHANNEL_MESSAGE}, + {"SoftKeyTemplateResMessage", SOFT_KEY_TEMPLATE_RES_MESSAGE}, + {"SoftKeySetResMessage", SOFT_KEY_SET_RES_MESSAGE}, + {"SelectSoftKeysMessage", SELECT_SOFT_KEYS_MESSAGE}, + {"CallStateMessage", CALL_STATE_MESSAGE}, + {"DisplayPromptStatusMessage", DISPLAY_PROMPT_STATUS_MESSAGE}, + {"ClearPromptStatusMessage", CLEAR_PROMPT_STATUS_MESSAGE}, + {"ActivateCallPlaneMessage", ACTIVATE_CALL_PLANE_MESSAGE}, + {"UnregisterAckMessage", UNREGISTER_ACK_MESSAGE}, + {"BackSpaceReqMessage", BACK_SPACE_REQ_MESSAGE}, + {"DialedNumberMessage", DIALED_NUMBER_MESSAGE}, + {"UserToDeviceDataMessage", USER_TO_DEVICE_DATA_MESSAGE}, + {"FeatureResMessage", FEATURE_STAT_RES_MESSAGE}, + {"DisplayPriNotifyMessage", DISPLAY_PRI_NOTIFY_MESSAGE}, + {"ServiceUrlStatMessage", SERVICE_URL_STAT_RES_MESSAGE}, + {"UserToDeviceDataVersion1Message", USER_TO_DEVICE_DATA_VERSION1_MESSAGE}, + {"XMLAlarmMessage", XML_ALARM_MESSAGE}, + {NULL, 0} }; SKINNY_DECLARE_ID2STR(skinny_message_type2str, SKINNY_MESSAGE_TYPES, "UnknownMessage") SKINNY_DECLARE_STR2ID(skinny_str2message_type, SKINNY_MESSAGE_TYPES, -1) @@ -216,6 +218,7 @@ struct skinny_table SKINNY_KEY_SETS[] = { {"KeySetConnectedWithConference", SKINNY_KEY_SET_CONNECTED_WITH_CONFERENCE}, {"KeySetRingOut", SKINNY_KEY_SET_RING_OUT}, {"KeySetOffHookWithFeatures", SKINNY_KEY_SET_OFF_HOOK_WITH_FEATURES}, + {"KeySetInUseHint", SKINNY_KEY_SET_IN_USE_HINT}, {NULL, 0} }; SKINNY_DECLARE_ID2STR(skinny_soft_key_set2str, SKINNY_KEY_SETS, "UNKNOWN_SOFT_KEY_SET") diff --git a/src/mod/endpoints/mod_skinny/skinny_tables.h b/src/mod/endpoints/mod_skinny/skinny_tables.h index bc92f9f4bf..00ddf0c74d 100644 --- a/src/mod/endpoints/mod_skinny/skinny_tables.h +++ b/src/mod/endpoints/mod_skinny/skinny_tables.h @@ -87,7 +87,7 @@ uint32_t func(const char *str)\ } -extern struct skinny_table SKINNY_MESSAGE_TYPES[67]; +extern struct skinny_table SKINNY_MESSAGE_TYPES[69]; const char *skinny_message_type2str(uint32_t id); uint32_t skinny_str2message_type(const char *str); #define SKINNY_PUSH_MESSAGE_TYPES SKINNY_DECLARE_PUSH_MATCH(SKINNY_MESSAGE_TYPES) @@ -210,8 +210,9 @@ enum skinny_key_set { SKINNY_KEY_SET_CONNECTED_WITH_CONFERENCE = 7, SKINNY_KEY_SET_RING_OUT = 8, SKINNY_KEY_SET_OFF_HOOK_WITH_FEATURES = 9, + SKINNY_KEY_SET_IN_USE_HINT = 10, }; -extern struct skinny_table SKINNY_KEY_SETS[11]; +extern struct skinny_table SKINNY_KEY_SETS[12]; const char *skinny_soft_key_set2str(uint32_t id); uint32_t skinny_str2soft_key_set(const char *str); #define SKINNY_PUSH_SOFT_KEY_SETS SKINNY_DECLARE_PUSH_MATCH(SKINNY_KEY_SETS) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 4853dff3bf..0921f1f313 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -1349,10 +1349,10 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi case SWITCH_MESSAGE_INDICATE_JITTER_BUFFER: { if (switch_rtp_ready(tech_pvt->rtp_session)) { - int len, maxlen = 0, qlen = 0, maxqlen = 50; + int len, maxlen = 0, qlen = 0, maxqlen = 50, max_drift = 0; if (msg->string_arg) { - char *p; + char *p, *q; const char *s; if (!strcasecmp(msg->string_arg, "pause")) { @@ -1379,6 +1379,10 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi if ((p = strchr(msg->string_arg, ':'))) { p++; maxlen = atol(p); + if ((q = strchr(p, ':'))) { + q++; + max_drift = abs(atol(q)); + } } } @@ -1391,9 +1395,10 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi if (qlen) { if (switch_rtp_activate_jitter_buffer(tech_pvt->rtp_session, qlen, maxqlen, tech_pvt->read_impl.samples_per_packet, - tech_pvt->read_impl.samples_per_second) == SWITCH_STATUS_SUCCESS) { + tech_pvt->read_impl.samples_per_second, max_drift) == SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), - SWITCH_LOG_DEBUG, "Setting Jitterbuffer to %dms (%d frames) (%d max frames)\n", len, qlen, maxqlen); + SWITCH_LOG_DEBUG, "Setting Jitterbuffer to %dms (%d frames) (%d max frames) (%d max drift)\n", + len, qlen, maxqlen, max_drift); switch_channel_set_flag(tech_pvt->channel, CF_JITTERBUFFER); } else { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), @@ -1439,10 +1444,13 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi case SWITCH_MESSAGE_INDICATE_BRIDGE: { + const char *var = switch_channel_get_variable(tech_pvt->channel, "sip_jitter_buffer_during_bridge"); + sofia_glue_tech_track(tech_pvt->profile, session); + sofia_glue_tech_simplify(tech_pvt); - if (switch_rtp_ready(tech_pvt->rtp_session)) { + if (switch_false(var) && switch_rtp_ready(tech_pvt->rtp_session)) { const char *val; int ok = 0; @@ -1477,6 +1485,8 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi const char *val; int ok = 0; + sofia_glue_tech_track(tech_pvt->profile, session); + if (switch_channel_test_flag(tech_pvt->channel, CF_JITTERBUFFER)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s RESUME Jitterbuffer\n", switch_channel_get_name(channel)); @@ -3513,7 +3523,7 @@ SWITCH_STANDARD_API(sofia_contact_function) profile = sofia_glue_find_profile(profile_name); } - if (!profile) { + if (!profile && !zstr(domain)) { profile = sofia_glue_find_profile(domain); } } @@ -4587,17 +4597,42 @@ static void general_event_handler(switch_event_t *event) case SWITCH_EVENT_TRAP: { const char *cond = switch_event_get_header(event, "condition"); + switch_hash_index_t *hi; + const void *var; + void *val; + sofia_profile_t *profile; + if (zstr(cond)) { + cond = ""; + } - if (cond && !strcmp(cond, "network-address-change") && mod_sofia_globals.auto_restart) { + if (!strcmp(cond, "network-external-address-change") && mod_sofia_globals.auto_restart) { + const char *old_ip4 = switch_event_get_header_nil(event, "network-external-address-previous-v4"); + const char *new_ip4 = switch_event_get_header_nil(event, "network-external-address-change-v4"); + + switch_mutex_lock(mod_sofia_globals.hash_mutex); + if (mod_sofia_globals.profile_hash && !zstr(old_ip4) && !zstr(new_ip4)) { + for (hi = switch_hash_first(NULL, mod_sofia_globals.profile_hash); hi; hi = switch_hash_next(hi)) { + switch_hash_this(hi, &var, NULL, &val); + + if ((profile = (sofia_profile_t *) val)) { + if (!zstr(profile->extsipip) && !strcmp(profile->extsipip, old_ip4)) { + profile->extsipip = switch_core_strdup(profile->pool, new_ip4); + } + + if (!zstr(profile->extrtpip) && !strcmp(profile->extrtpip, old_ip4)) { + profile->extrtpip = switch_core_strdup(profile->pool, new_ip4); + } + } + } + } + switch_mutex_unlock(mod_sofia_globals.hash_mutex); + sofia_glue_restart_all_profiles(); + } else if (!strcmp(cond, "network-address-change") && mod_sofia_globals.auto_restart) { const char *old_ip4 = switch_event_get_header_nil(event, "network-address-previous-v4"); const char *new_ip4 = switch_event_get_header_nil(event, "network-address-change-v4"); const char *old_ip6 = switch_event_get_header_nil(event, "network-address-previous-v6"); const char *new_ip6 = switch_event_get_header_nil(event, "network-address-change-v6"); - switch_hash_index_t *hi; - const void *var; - void *val; - sofia_profile_t *profile; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "EVENT_TRAP: IP change detected\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "IP change detected [%s]->[%s] [%s]->[%s]\n", old_ip4, new_ip4, old_ip6, new_ip6); diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 8a3d1b10f6..90193ac63a 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -2135,7 +2135,7 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag) register_transport = (char *) sofia_glue_transport2str(gateway->register_transport); - if (contact_params) { + if (! zstr(contact_params)) { if (*contact_params == ';') { params = switch_core_sprintf(gateway->pool, "%s;transport=%s;gw=%s", contact_params, register_transport, gateway->name); } else { diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index 01a70f32b6..a76467f5d8 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -3166,12 +3166,16 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f if ((val = switch_channel_get_variable(tech_pvt->channel, "jitterbuffer_msec")) || (val = tech_pvt->profile->jb_msec)) { int jb_msec = atoi(val); - int maxlen = 0; - char *p; - + int maxlen = 0, max_drift = 0; + char *p, *q; + if ((p = strchr(val, ':'))) { p++; maxlen = atoi(p); + if ((q = strchr(p, ':'))) { + q++; + max_drift = abs(atoi(q)); + } } if (jb_msec < 20 || jb_msec > 10000) { @@ -3188,7 +3192,7 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f if (switch_rtp_activate_jitter_buffer(tech_pvt->rtp_session, qlen, maxqlen, tech_pvt->read_impl.samples_per_packet, - tech_pvt->read_impl.samples_per_second) == SWITCH_STATUS_SUCCESS) { + tech_pvt->read_impl.samples_per_second, max_drift) == SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Setting Jitterbuffer to %dms (%d frames)\n", jb_msec, qlen); switch_channel_set_flag(tech_pvt->channel, CF_JITTERBUFFER); @@ -3238,7 +3242,9 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f } if (tech_pvt->audio_recv_pt != tech_pvt->agreed_pt) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_CRIT, "Set audio receive payload to %u\n", tech_pvt->audio_recv_pt); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, + "%s Set audio receive payload to %u\n", switch_channel_get_name(tech_pvt->channel), tech_pvt->audio_recv_pt); + switch_rtp_set_recv_pt(tech_pvt->rtp_session, tech_pvt->audio_recv_pt); } @@ -3423,8 +3429,8 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f if (tech_pvt->video_recv_pt != tech_pvt->video_agreed_pt) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, - "Set video receive payload to %u\n", tech_pvt->video_recv_pt); - switch_rtp_set_recv_pt(tech_pvt->rtp_session, tech_pvt->video_recv_pt); + "%s Set video receive payload to %u\n", switch_channel_get_name(tech_pvt->channel), tech_pvt->video_recv_pt); + switch_rtp_set_recv_pt(tech_pvt->video_rtp_session, tech_pvt->video_recv_pt); } switch_channel_set_variable_printf(tech_pvt->channel, "sip_use_video_pt", "%d", tech_pvt->video_agreed_pt); @@ -3484,6 +3490,59 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f } +static void add_audio_codec(sdp_rtpmap_t *map, int ptime, char *buf, switch_size_t buflen) +{ + int codec_ms = ptime; + uint32_t map_bit_rate = 0; + char ptstr[20] = ""; + char ratestr[20] = ""; + char bitstr[20] = ""; + switch_codec_fmtp_t codec_fmtp = { 0 }; + + if (!codec_ms) { + codec_ms = switch_default_ptime(map->rm_encoding, map->rm_pt); + } + + map_bit_rate = switch_known_bitrate(map->rm_pt); + + if (!ptime && !strcasecmp(map->rm_encoding, "g723")) { + ptime = codec_ms = 30; + } + + if (zstr(map->rm_fmtp)) { + if (!strcasecmp(map->rm_encoding, "ilbc")) { + ptime = codec_ms = 30; + map_bit_rate = 13330; + } + } else { + if ((switch_core_codec_parse_fmtp(map->rm_encoding, map->rm_fmtp, map->rm_rate, &codec_fmtp)) == SWITCH_STATUS_SUCCESS) { + if (codec_fmtp.bits_per_second) { + map_bit_rate = codec_fmtp.bits_per_second; + } + if (codec_fmtp.microseconds_per_packet) { + codec_ms = (codec_fmtp.microseconds_per_packet / 1000); + } + } + } + + if (map->rm_rate) { + switch_snprintf(ratestr, sizeof(ratestr), "@%uh", (unsigned int) map->rm_rate); + } + + if (codec_ms) { + switch_snprintf(ptstr, sizeof(ptstr), "@%di", codec_ms); + } + + if (map_bit_rate) { + switch_snprintf(bitstr, sizeof(bitstr), "@%db", map_bit_rate); + } + + switch_snprintf(buf + strlen(buf), buflen - strlen(buf), ",%s%s%s%s", map->rm_encoding, ratestr, ptstr, bitstr); + +} + + + void sofia_glue_set_r_sdp_codec_string(switch_core_session_t *session, const char *codec_string, sdp_session_t *sdp) { char buf[1024] = { 0 }; @@ -3500,7 +3559,13 @@ void sofia_glue_set_r_sdp_codec_string(switch_core_session_t *session, const cha const switch_codec_implementation_t *codecs[SWITCH_MAX_CODECS] = { 0 }; switch_channel_t *channel = switch_core_session_get_channel(session); private_object_t *tech_pvt = switch_core_session_get_private(session); + int prefer_sdp = 0; + const char *var; + if ((var = switch_channel_get_variable(channel, "ep_codec_prefer_sdp")) && switch_true(var)) { + prefer_sdp = 1; + } + if (!zstr(codec_string)) { char *tmp_codec_string; if ((tmp_codec_string = strdup(codec_string))) { @@ -3551,78 +3616,62 @@ void sofia_glue_set_r_sdp_codec_string(switch_core_session_t *session, const cha break; } - for (i = 0; i < num_codecs; i++) { - const switch_codec_implementation_t *imp = codecs[i]; - if (imp->codec_type != SWITCH_CODEC_TYPE_AUDIO || imp->ianacode > 127 || already_did[imp->ianacode]) { - continue; - } + if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_INBOUND || prefer_sdp) { for (map = m->m_rtpmaps; map; map = map->rm_next) { if (map->rm_pt > 127 || already_did[map->rm_pt]) { continue; } - if ((zstr(map->rm_encoding) || (tech_pvt->profile->ndlb & PFLAG_NDLB_ALLOW_BAD_IANANAME)) && map->rm_pt < 96) { - match = (map->rm_pt == imp->ianacode) ? 1 : 0; - } else { - if (map->rm_encoding) { - match = strcasecmp(map->rm_encoding, imp->iananame) ? 0 : 1; + for (i = 0; i < num_codecs; i++) { + const switch_codec_implementation_t *imp = codecs[i]; + + if ((zstr(map->rm_encoding) || (tech_pvt->profile->ndlb & PFLAG_NDLB_ALLOW_BAD_IANANAME)) && map->rm_pt < 96) { + match = (map->rm_pt == imp->ianacode) ? 1 : 0; } else { - match = 0; + if (map->rm_encoding) { + match = strcasecmp(map->rm_encoding, imp->iananame) ? 0 : 1; + } else { + match = 0; + } } + + if (match) { + add_audio_codec(map, ptime, buf, sizeof(buf)); + break; + } + } + } - if (match) { - int codec_ms = ptime; - uint32_t map_bit_rate = 0; - char ptstr[20] = ""; - char ratestr[20] = ""; - char bitstr[20] = ""; - switch_codec_fmtp_t codec_fmtp = { 0 }; - - if (!codec_ms) { - codec_ms = switch_default_ptime(map->rm_encoding, map->rm_pt); + } else { + for (i = 0; i < num_codecs; i++) { + const switch_codec_implementation_t *imp = codecs[i]; + if (imp->codec_type != SWITCH_CODEC_TYPE_AUDIO || imp->ianacode > 127 || already_did[imp->ianacode]) { + continue; + } + for (map = m->m_rtpmaps; map; map = map->rm_next) { + if (map->rm_pt > 127 || already_did[map->rm_pt]) { + continue; } - map_bit_rate = switch_known_bitrate(map->rm_pt); - - if (!ptime && !strcasecmp(map->rm_encoding, "g723")) { - ptime = codec_ms = 30; - } - - if (zstr(map->rm_fmtp)) { - if (!strcasecmp(map->rm_encoding, "ilbc")) { - ptime = codec_ms = 30; - map_bit_rate = 13330; - } + if ((zstr(map->rm_encoding) || (tech_pvt->profile->ndlb & PFLAG_NDLB_ALLOW_BAD_IANANAME)) && map->rm_pt < 96) { + match = (map->rm_pt == imp->ianacode) ? 1 : 0; } else { - if ((switch_core_codec_parse_fmtp(map->rm_encoding, map->rm_fmtp, map->rm_rate, &codec_fmtp)) == SWITCH_STATUS_SUCCESS) { - if (codec_fmtp.bits_per_second) { - map_bit_rate = codec_fmtp.bits_per_second; - } - if (codec_fmtp.microseconds_per_packet) { - codec_ms = (codec_fmtp.microseconds_per_packet / 1000); - } + if (map->rm_encoding) { + match = strcasecmp(map->rm_encoding, imp->iananame) ? 0 : 1; + } else { + match = 0; } } - if (map->rm_rate) { - switch_snprintf(ratestr, sizeof(ratestr), "@%uh", (unsigned int) map->rm_rate); + if (match) { + add_audio_codec(map, ptime, buf, sizeof(buf)); + break; } - - if (codec_ms) { - switch_snprintf(ptstr, sizeof(ptstr), "@%di", codec_ms); - } - - if (map_bit_rate) { - switch_snprintf(bitstr, sizeof(bitstr), "@%db", map_bit_rate); - } - - switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), ",%s%s%s%s", map->rm_encoding, ratestr, ptstr, bitstr); - - break; } } } + } else if (m->m_type == sdp_media_video && m->m_port) { connection = sdp->sdp_connection; if (m->m_connections) { @@ -3814,6 +3863,7 @@ static switch_t38_options_t *tech_process_udptl(private_object_t *tech_pvt, sdp_ { switch_t38_options_t *t38_options = switch_channel_get_private(tech_pvt->channel, "t38_options"); sdp_attribute_t *attr; + const char *var; if (!t38_options) { t38_options = switch_core_session_alloc(tech_pvt->session, sizeof(switch_t38_options_t)); @@ -3893,6 +3943,21 @@ static switch_t38_options_t *tech_process_udptl(private_object_t *tech_pvt, sdp_ switch_channel_set_private(tech_pvt->channel, "t38_options", t38_options); switch_channel_set_app_flag_key("T38", tech_pvt->channel, CF_APP_T38); + if ((var = switch_channel_get_variable(tech_pvt->channel, "sip_execute_on_image"))) { + char *app, *arg = NULL; + app = switch_core_session_strdup(tech_pvt->session, var); + + if (strstr(app, "::")) { + switch_core_session_execute_application_async(tech_pvt->session, app, arg); + } else { + if ((arg = strchr(app, ' '))) { + *arg++ = '\0'; + } + + switch_core_session_execute_application(tech_pvt->session, app, arg); + } + } + return t38_options; } @@ -5166,7 +5231,7 @@ static int recover_callback(void *pArg, int argc, char **argv, char **columnName tech_pvt->local_sdp_str = switch_core_session_strdup(session, tmp); } - if ((tmp = switch_channel_get_variable(channel, "switch_r_sdp"))) { + if ((tmp = switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE))) { tech_pvt->remote_sdp_str = switch_core_session_strdup(session, tmp); } diff --git a/src/mod/endpoints/mod_sofia/sofia_presence.c b/src/mod/endpoints/mod_sofia/sofia_presence.c index 89eb1ae948..91808a7f50 100644 --- a/src/mod/endpoints/mod_sofia/sofia_presence.c +++ b/src/mod/endpoints/mod_sofia/sofia_presence.c @@ -91,6 +91,7 @@ switch_status_t sofia_presence_chat_send(const char *proto, const char *from, co char *user_via = NULL; char *contact_str = NULL; char *dup_dest = NULL; + char *p = NULL; char *remote_host = NULL; if (!to) { @@ -187,7 +188,12 @@ switch_status_t sofia_presence_chat_send(const char *proto, const char *from, co /* sofia_glue is running sofia_overcome_sip_uri_weakness we do not, not sure if it matters */ - dup_dest = strdup(dst->contact); + if (dst->route_uri) { + dup_dest = strdup(dst->route_uri); + } else { + dup_dest = strdup(dst->to); + } + if (dst->route_uri) { remote_host = strdup(dst->route_uri); @@ -226,17 +232,12 @@ switch_status_t sofia_presence_chat_send(const char *proto, const char *from, co contact_str = profile->url; } - switch_safe_free(dup_dest); - switch_safe_free(remote_host); - status = SWITCH_STATUS_SUCCESS; - /* - if ((p = strstr(contact, ";fs_"))) { + if (dup_dest && (p = strstr(dup_dest, ";fs_"))) { *p = '\0'; } - */ - + /* if this cries, add contact here too, change the 1 to 0 and omit the safe_free */ msg_nh = nua_handle(profile->nua, NULL, @@ -244,7 +245,7 @@ switch_status_t sofia_presence_chat_send(const char *proto, const char *from, co TAG_IF(dst->route, SIPTAG_ROUTE_STR(dst->route)), SIPTAG_FROM_STR(from), TAG_IF(contact, NUTAG_URL(contact)), - SIPTAG_TO_STR(dst->to), + SIPTAG_TO_STR(dup_dest), SIPTAG_CONTACT_STR(contact_str), TAG_END()); @@ -257,6 +258,8 @@ switch_status_t sofia_presence_chat_send(const char *proto, const char *from, co TAG_END()); sofia_glue_free_destination(dst); + switch_safe_free(dup_dest); + switch_safe_free(remote_host); } switch_console_free_matches(&list); diff --git a/src/mod/endpoints/mod_sofia/sofia_reg.c b/src/mod/endpoints/mod_sofia/sofia_reg.c index 5109e0bc72..6e3649a68f 100644 --- a/src/mod/endpoints/mod_sofia/sofia_reg.c +++ b/src/mod/endpoints/mod_sofia/sofia_reg.c @@ -653,7 +653,7 @@ void sofia_reg_check_expire(sofia_profile_t *profile, time_t now, int reboot) "and profile_name='%s' and expires <= %ld", mod_sofia_globals.hostname, profile->name, (long) now); sofia_glue_execute_sql_callback(profile, NULL, sql, sofia_sla_dialog_del_callback, profile); - switch_snprintf(sql, sizeof(sql), "delete from sip_registrations where expires > 0 and hostname='%s' and expires <= %ld", + switch_snprintf(sql, sizeof(sql), "delete from sip_shared_appearance_dialogs where expires > 0 and hostname='%s' and expires <= %ld", mod_sofia_globals.hostname, (long) now); diff --git a/src/mod/event_handlers/mod_snmp/Makefile b/src/mod/event_handlers/mod_snmp/Makefile index 1d8827daf1..f95227b4b5 100644 --- a/src/mod/event_handlers/mod_snmp/Makefile +++ b/src/mod/event_handlers/mod_snmp/Makefile @@ -1,6 +1,6 @@ include ../../../../build/modmake.rules -LOCAL_CFLAGS=-I `net-snmp-config --cflags` +LOCAL_CFLAGS=`net-snmp-config --cflags` LOCAL_LDFLAGS=`net-snmp-config --agent-libs` LOCAL_OBJS=subagent.o diff --git a/src/mod/event_handlers/mod_snmp/subagent.c b/src/mod/event_handlers/mod_snmp/subagent.c index 43975ee4e0..871fb5ad75 100644 --- a/src/mod/event_handlers/mod_snmp/subagent.c +++ b/src/mod/event_handlers/mod_snmp/subagent.c @@ -67,42 +67,42 @@ static int channelList_callback(void *pArg, int argc, char **argv, char **column netsnmp_tdata_row *row; switch_zmalloc(entry, sizeof(chan_entry_t)); - if (!entry) - return 0; row = netsnmp_tdata_create_row(); + if (!row) { switch_safe_free(entry); return 0; } + row->data = entry; entry->idx = idx++; - strncpy(entry->uuid, argv[0], sizeof(entry->uuid)); - strncpy(entry->direction, argv[1], sizeof(entry->direction)); + strncpy(entry->uuid, switch_str_nil(argv[0]), sizeof(entry->uuid)); + strncpy(entry->direction, switch_str_nil(argv[1]), sizeof(entry->direction)); entry->created_epoch = atoi(argv[3]); - strncpy(entry->name, argv[4], sizeof(entry->name)); - strncpy(entry->state, argv[5], sizeof(entry->state)); - strncpy(entry->cid_name, argv[6], sizeof(entry->cid_name)); - strncpy(entry->cid_num, argv[7], sizeof(entry->cid_num)); - strncpy(entry->dest, argv[9], sizeof(entry->dest)); - strncpy(entry->application, argv[10], sizeof(entry->application)); - strncpy(entry->application_data, argv[11], sizeof(entry->application_data)); - strncpy(entry->dialplan, argv[12], sizeof(entry->dialplan)); - strncpy(entry->context, argv[13], sizeof(entry->context)); - strncpy(entry->read_codec, argv[14], sizeof(entry->read_codec)); - entry->read_rate = atoi(argv[15]); - entry->read_bitrate = atoi(argv[16]); - strncpy(entry->write_codec, argv[17], sizeof(entry->write_codec)); - entry->write_rate = atoi(argv[18]); - entry->write_bitrate = atoi(argv[19]); + strncpy(entry->name, switch_str_nil(argv[4]), sizeof(entry->name)); + strncpy(entry->state, switch_str_nil(argv[5]), sizeof(entry->state)); + strncpy(entry->cid_name, switch_str_nil(argv[6]), sizeof(entry->cid_name)); + strncpy(entry->cid_num, switch_str_nil(argv[7]), sizeof(entry->cid_num)); + strncpy(entry->dest, switch_str_nil(argv[9]), sizeof(entry->dest)); + strncpy(entry->application, switch_str_nil(argv[10]), sizeof(entry->application)); + strncpy(entry->application_data, switch_str_nil(argv[11]), sizeof(entry->application_data)); + strncpy(entry->dialplan, switch_str_nil(argv[12]), sizeof(entry->dialplan)); + strncpy(entry->context, switch_str_nil(argv[13]), sizeof(entry->context)); + strncpy(entry->read_codec, switch_str_nil(argv[14]), sizeof(entry->read_codec)); + entry->read_rate = atoi(switch_str_nil(argv[15])); + entry->read_bitrate = atoi(switch_str_nil(argv[16])); + strncpy(entry->write_codec, switch_str_nil(argv[17]), sizeof(entry->write_codec)); + entry->write_rate = atoi(switch_str_nil(argv[18])); + entry->write_bitrate = atoi(switch_str_nil(argv[19])); memset(&entry->ip_addr, 0, sizeof(entry->ip_addr)); - if (strchr(argv[8], ':')) { - switch_inet_pton(AF_INET6, argv[8], &entry->ip_addr); + if (strchr(switch_str_nil(argv[8]), ':')) { + switch_inet_pton(AF_INET6, switch_str_nil(argv[8]), &entry->ip_addr); entry->addr_family = AF_INET6; } else { - switch_inet_pton(AF_INET, argv[8], &entry->ip_addr); + switch_inet_pton(AF_INET, switch_str_nil(argv[8]), &entry->ip_addr); entry->addr_family = AF_INET; } @@ -128,7 +128,7 @@ void channelList_free(netsnmp_cache *cache, void *magic) int channelList_load(netsnmp_cache *cache, void *vmagic) { switch_cache_db_handle_t *dbh; - char sql[1024] = "", hostname[256] = ""; + char sql[1024] = ""; channelList_free(cache, NULL); @@ -137,8 +137,8 @@ int channelList_load(netsnmp_cache *cache, void *vmagic) } idx = 1; - gethostname(hostname, sizeof(hostname)); - sprintf(sql, "SELECT * FROM channels WHERE hostname='%s' ORDER BY created_epoch", hostname); + + sprintf(sql, "SELECT * FROM channels WHERE hostname='%s' ORDER BY created_epoch", switch_core_get_hostname()); switch_cache_db_execute_sql_callback(dbh, sql, channelList_callback, NULL, NULL); switch_cache_db_release_db_handle(&dbh); @@ -282,6 +282,9 @@ int handle_channelList(netsnmp_mib_handler *handler, netsnmp_handler_registratio switch (reqinfo->mode) { case MODE_GET: for (request = requests; request; request = request->next) { + if (request->processed) + continue; + table_info = netsnmp_extract_table_info(request); entry = (chan_entry_t *) netsnmp_tdata_extract_entry(request); @@ -366,7 +369,7 @@ int handle_channelList(netsnmp_mib_handler *handler, netsnmp_handler_registratio break; default: /* we should never get here, so this is a really bad error */ - snmp_log(LOG_ERR, "Unknown mode (%d) in handle_foo\n", reqinfo->mode ); + snmp_log(LOG_ERR, "Unknown mode (%d) in handle_channelList\n", reqinfo->mode ); return SNMP_ERR_GENERR; } diff --git a/src/mod/formats/mod_shout/Makefile b/src/mod/formats/mod_shout/Makefile index 0ff6fc6525..7388bc0c67 100644 --- a/src/mod/formats/mod_shout/Makefile +++ b/src/mod/formats/mod_shout/Makefile @@ -1,6 +1,6 @@ LAME=lame-3.97 SHOUT=libshout-2.2.2 -MPG123=mpg123 +MPG123=mpg123-1.13.2 BASE=../../../.. WANT_CURL=yes diff --git a/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitch.java b/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitch.java index 7b53db475c..ea825c9014 100644 --- a/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitch.java +++ b/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitch.java @@ -17,6 +17,10 @@ public class freeswitch { freeswitchJNI.consoleCleanLog(msg); } + public static boolean email(String to, String from, String headers, String body, String file, String convert_cmd, String convert_ext) { + return freeswitchJNI.email(to, from, headers, body, file, convert_cmd, convert_ext); + } + public static void console_log(String level_str, String msg) { freeswitchJNI.console_log(level_str, msg); } diff --git a/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java b/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java index f90a9cca11..5e778de59c 100644 --- a/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java +++ b/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java @@ -11,6 +11,7 @@ package org.freeswitch.swig; class freeswitchJNI { public final static native void consoleLog(String jarg1, String jarg2); public final static native void consoleCleanLog(String jarg1); + public final static native boolean email(String jarg1, String jarg2, String jarg3, String jarg4, String jarg5, String jarg6, String jarg7); public final static native long new_IVRMenu(long jarg1, IVRMenu jarg1_, String jarg2, String jarg3, String jarg4, String jarg5, String jarg6, String jarg7, String jarg8, String jarg9, String jarg10, int jarg11, int jarg12, int jarg13, int jarg14, int jarg15, int jarg16); public final static native void delete_IVRMenu(long jarg1); public final static native void IVRMenu_bindAction(long jarg1, IVRMenu jarg1_, String jarg2, String jarg3, String jarg4); diff --git a/src/mod/languages/mod_java/switch_swig_wrap.cpp b/src/mod/languages/mod_java/switch_swig_wrap.cpp index 720e7571db..34f62d5c9d 100644 --- a/src/mod/languages/mod_java/switch_swig_wrap.cpp +++ b/src/mod/languages/mod_java/switch_swig_wrap.cpp @@ -244,6 +244,67 @@ SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_consoleCleanLog(J } +SWIGEXPORT jboolean JNICALL Java_org_freeswitch_swig_freeswitchJNI_email(JNIEnv *jenv, jclass jcls, jstring jarg1, jstring jarg2, jstring jarg3, jstring jarg4, jstring jarg5, jstring jarg6, jstring jarg7) { + jboolean jresult = 0 ; + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) NULL ; + char *arg4 = (char *) NULL ; + char *arg5 = (char *) NULL ; + char *arg6 = (char *) NULL ; + char *arg7 = (char *) NULL ; + bool result; + + (void)jenv; + (void)jcls; + arg1 = 0; + if (jarg1) { + arg1 = (char *)jenv->GetStringUTFChars(jarg1, 0); + if (!arg1) return 0; + } + arg2 = 0; + if (jarg2) { + arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0); + if (!arg2) return 0; + } + arg3 = 0; + if (jarg3) { + arg3 = (char *)jenv->GetStringUTFChars(jarg3, 0); + if (!arg3) return 0; + } + arg4 = 0; + if (jarg4) { + arg4 = (char *)jenv->GetStringUTFChars(jarg4, 0); + if (!arg4) return 0; + } + arg5 = 0; + if (jarg5) { + arg5 = (char *)jenv->GetStringUTFChars(jarg5, 0); + if (!arg5) return 0; + } + arg6 = 0; + if (jarg6) { + arg6 = (char *)jenv->GetStringUTFChars(jarg6, 0); + if (!arg6) return 0; + } + arg7 = 0; + if (jarg7) { + arg7 = (char *)jenv->GetStringUTFChars(jarg7, 0); + if (!arg7) return 0; + } + result = (bool)email(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + jresult = (jboolean)result; + if (arg1) jenv->ReleaseStringUTFChars(jarg1, (const char *)arg1); + if (arg2) jenv->ReleaseStringUTFChars(jarg2, (const char *)arg2); + if (arg3) jenv->ReleaseStringUTFChars(jarg3, (const char *)arg3); + if (arg4) jenv->ReleaseStringUTFChars(jarg4, (const char *)arg4); + if (arg5) jenv->ReleaseStringUTFChars(jarg5, (const char *)arg5); + if (arg6) jenv->ReleaseStringUTFChars(jarg6, (const char *)arg6); + if (arg7) jenv->ReleaseStringUTFChars(jarg7, (const char *)arg7); + return jresult; +} + + SWIGEXPORT jlong JNICALL Java_org_freeswitch_swig_freeswitchJNI_new_1IVRMenu(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jstring jarg3, jstring jarg4, jstring jarg5, jstring jarg6, jstring jarg7, jstring jarg8, jstring jarg9, jstring jarg10, jint jarg11, jint jarg12, jint jarg13, jint jarg14, jint jarg15, jint jarg16) { jlong jresult = 0 ; IVRMenu *arg1 = (IVRMenu *) 0 ; diff --git a/src/mod/languages/mod_managed/freeswitch_wrap.2010.cxx b/src/mod/languages/mod_managed/freeswitch_wrap.2010.cxx index 808d548bdf..fdf2c5f08d 100644 --- a/src/mod/languages/mod_managed/freeswitch_wrap.2010.cxx +++ b/src/mod/languages/mod_managed/freeswitch_wrap.2010.cxx @@ -7182,6 +7182,42 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_switch_core_get_variable(char * jarg1) { } +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_core_get_variable_dup(char * jarg1) { + char * jresult ; + char *arg1 = (char *) 0 ; + char *result = 0 ; + + arg1 = (char *)jarg1; + result = (char *)switch_core_get_variable_dup((char const *)arg1); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_core_get_variable_pdup(char * jarg1, void * jarg2) { + char * jresult ; + char *arg1 = (char *) 0 ; + switch_memory_pool_t *arg2 = (switch_memory_pool_t *) 0 ; + char *result = 0 ; + + arg1 = (char *)jarg1; + arg2 = (switch_memory_pool_t *)jarg2; + result = (char *)switch_core_get_variable_pdup((char const *)arg1,arg2); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_core_get_hostname() { + char * jresult ; + char *result = 0 ; + + result = (char *)switch_core_get_hostname(); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_set_variable(char * jarg1, char * jarg2) { char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; @@ -10071,293 +10107,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_cache_db_connection_options_t(v } -SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_handle_t_name_set(void * jarg1, char * jarg2) { - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - char *arg2 ; - - arg1 = (switch_cache_db_handle_t *)jarg1; - arg2 = (char *)jarg2; - { - if(arg2) { - strncpy((char*)arg1->name, (const char *)arg2, 256-1); - arg1->name[256-1] = 0; - } else { - arg1->name[0] = 0; - } - } -} - - -SWIGEXPORT char * SWIGSTDCALL CSharp_switch_cache_db_handle_t_name_get(void * jarg1) { - char * jresult ; - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - char *result = 0 ; - - arg1 = (switch_cache_db_handle_t *)jarg1; - result = (char *)(char *) ((arg1)->name); - jresult = SWIG_csharp_string_callback((const char *)result); - return jresult; -} - - -SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_handle_t_type_set(void * jarg1, int jarg2) { - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - switch_cache_db_handle_type_t arg2 ; - - arg1 = (switch_cache_db_handle_t *)jarg1; - arg2 = (switch_cache_db_handle_type_t)jarg2; - if (arg1) (arg1)->type = arg2; -} - - -SWIGEXPORT int SWIGSTDCALL CSharp_switch_cache_db_handle_t_type_get(void * jarg1) { - int jresult ; - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - switch_cache_db_handle_type_t result; - - arg1 = (switch_cache_db_handle_t *)jarg1; - result = (switch_cache_db_handle_type_t) ((arg1)->type); - jresult = result; - return jresult; -} - - -SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_handle_t_native_handle_set(void * jarg1, void * jarg2) { - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - switch_cache_db_native_handle_t *arg2 = (switch_cache_db_native_handle_t *) 0 ; - - arg1 = (switch_cache_db_handle_t *)jarg1; - arg2 = (switch_cache_db_native_handle_t *)jarg2; - if (arg1) (arg1)->native_handle = *arg2; -} - - -SWIGEXPORT void * SWIGSTDCALL CSharp_switch_cache_db_handle_t_native_handle_get(void * jarg1) { - void * jresult ; - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - switch_cache_db_native_handle_t *result = 0 ; - - arg1 = (switch_cache_db_handle_t *)jarg1; - result = (switch_cache_db_native_handle_t *)& ((arg1)->native_handle); - jresult = (void *)result; - return jresult; -} - - -SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_handle_t_last_used_set(void * jarg1, void * jarg2) { - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - time_t arg2 ; - time_t *argp2 ; - - arg1 = (switch_cache_db_handle_t *)jarg1; - argp2 = (time_t *)jarg2; - if (!argp2) { - SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null time_t", 0); - return ; - } - arg2 = *argp2; - if (arg1) (arg1)->last_used = arg2; -} - - -SWIGEXPORT void * SWIGSTDCALL CSharp_switch_cache_db_handle_t_last_used_get(void * jarg1) { - void * jresult ; - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - time_t result; - - arg1 = (switch_cache_db_handle_t *)jarg1; - result = ((arg1)->last_used); - jresult = new time_t((const time_t &)result); - return jresult; -} - - -SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_handle_t_mutex_set(void * jarg1, void * jarg2) { - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - switch_mutex_t *arg2 = (switch_mutex_t *) 0 ; - - arg1 = (switch_cache_db_handle_t *)jarg1; - arg2 = (switch_mutex_t *)jarg2; - if (arg1) (arg1)->mutex = arg2; -} - - -SWIGEXPORT void * SWIGSTDCALL CSharp_switch_cache_db_handle_t_mutex_get(void * jarg1) { - void * jresult ; - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - switch_mutex_t *result = 0 ; - - arg1 = (switch_cache_db_handle_t *)jarg1; - result = (switch_mutex_t *) ((arg1)->mutex); - jresult = (void *)result; - return jresult; -} - - -SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_handle_t_io_mutex_set(void * jarg1, void * jarg2) { - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - switch_mutex_t *arg2 = (switch_mutex_t *) 0 ; - - arg1 = (switch_cache_db_handle_t *)jarg1; - arg2 = (switch_mutex_t *)jarg2; - if (arg1) (arg1)->io_mutex = arg2; -} - - -SWIGEXPORT void * SWIGSTDCALL CSharp_switch_cache_db_handle_t_io_mutex_get(void * jarg1) { - void * jresult ; - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - switch_mutex_t *result = 0 ; - - arg1 = (switch_cache_db_handle_t *)jarg1; - result = (switch_mutex_t *) ((arg1)->io_mutex); - jresult = (void *)result; - return jresult; -} - - -SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_handle_t_pool_set(void * jarg1, void * jarg2) { - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - switch_memory_pool_t *arg2 = (switch_memory_pool_t *) 0 ; - - arg1 = (switch_cache_db_handle_t *)jarg1; - arg2 = (switch_memory_pool_t *)jarg2; - if (arg1) (arg1)->pool = arg2; -} - - -SWIGEXPORT void * SWIGSTDCALL CSharp_switch_cache_db_handle_t_pool_get(void * jarg1) { - void * jresult ; - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - switch_memory_pool_t *result = 0 ; - - arg1 = (switch_cache_db_handle_t *)jarg1; - result = (switch_memory_pool_t *) ((arg1)->pool); - jresult = (void *)result; - return jresult; -} - - -SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_handle_t_flags_set(void * jarg1, int jarg2) { - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - int32_t arg2 ; - - arg1 = (switch_cache_db_handle_t *)jarg1; - arg2 = (int32_t)jarg2; - if (arg1) (arg1)->flags = arg2; -} - - -SWIGEXPORT int SWIGSTDCALL CSharp_switch_cache_db_handle_t_flags_get(void * jarg1) { - int jresult ; - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - int32_t result; - - arg1 = (switch_cache_db_handle_t *)jarg1; - result = (int32_t) ((arg1)->flags); - jresult = result; - return jresult; -} - - -SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_handle_t_hash_set(void * jarg1, unsigned long jarg2) { - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - unsigned long arg2 ; - - arg1 = (switch_cache_db_handle_t *)jarg1; - arg2 = (unsigned long)jarg2; - if (arg1) (arg1)->hash = arg2; -} - - -SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_cache_db_handle_t_hash_get(void * jarg1) { - unsigned long jresult ; - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - unsigned long result; - - arg1 = (switch_cache_db_handle_t *)jarg1; - result = (unsigned long) ((arg1)->hash); - jresult = (unsigned long)result; - return jresult; -} - - -SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_handle_t_creator_set(void * jarg1, char * jarg2) { - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - char *arg2 ; - - arg1 = (switch_cache_db_handle_t *)jarg1; - arg2 = (char *)jarg2; - { - if(arg2) { - strncpy((char*)arg1->creator, (const char *)arg2, 256-1); - arg1->creator[256-1] = 0; - } else { - arg1->creator[0] = 0; - } - } -} - - -SWIGEXPORT char * SWIGSTDCALL CSharp_switch_cache_db_handle_t_creator_get(void * jarg1) { - char * jresult ; - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - char *result = 0 ; - - arg1 = (switch_cache_db_handle_t *)jarg1; - result = (char *)(char *) ((arg1)->creator); - jresult = SWIG_csharp_string_callback((const char *)result); - return jresult; -} - - -SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_handle_t_last_user_set(void * jarg1, char * jarg2) { - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - char *arg2 ; - - arg1 = (switch_cache_db_handle_t *)jarg1; - arg2 = (char *)jarg2; - { - if(arg2) { - strncpy((char*)arg1->last_user, (const char *)arg2, 256-1); - arg1->last_user[256-1] = 0; - } else { - arg1->last_user[0] = 0; - } - } -} - - -SWIGEXPORT char * SWIGSTDCALL CSharp_switch_cache_db_handle_t_last_user_get(void * jarg1) { - char * jresult ; - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - char *result = 0 ; - - arg1 = (switch_cache_db_handle_t *)jarg1; - result = (char *)(char *) ((arg1)->last_user); - jresult = SWIG_csharp_string_callback((const char *)result); - return jresult; -} - - -SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_cache_db_handle_t() { - void * jresult ; - switch_cache_db_handle_t *result = 0 ; - - result = (switch_cache_db_handle_t *)new switch_cache_db_handle_t(); - jresult = (void *)result; - return jresult; -} - - -SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_cache_db_handle_t(void * jarg1) { - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - - arg1 = (switch_cache_db_handle_t *)jarg1; - delete arg1; -} - - SWIGEXPORT char * SWIGSTDCALL CSharp_switch_cache_db_type_name(int jarg1) { char * jresult ; switch_cache_db_handle_type_t arg1 ; @@ -10370,6 +10119,18 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_switch_cache_db_type_name(int jarg1) { } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_cache_db_get_type(void * jarg1) { + int jresult ; + switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; + switch_cache_db_handle_type_t result; + + arg1 = (switch_cache_db_handle_t *)jarg1; + result = (switch_cache_db_handle_type_t)switch_cache_db_get_type(arg1); + jresult = result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_dismiss_db_handle(void * jarg1) { switch_cache_db_handle_t **arg1 = (switch_cache_db_handle_t **) 0 ; @@ -10386,14 +10147,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_release_db_handle(void * jarg } -SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_destroy_db_handle(void * jarg1) { - switch_cache_db_handle_t **arg1 = (switch_cache_db_handle_t **) 0 ; - - arg1 = (switch_cache_db_handle_t **)jarg1; - switch_cache_db_destroy_db_handle(arg1); -} - - SWIGEXPORT int SWIGSTDCALL CSharp__switch_cache_db_get_db_handle(void * jarg1, int jarg2, void * jarg3, char * jarg4, char * jarg5, int jarg6) { int jresult ; switch_cache_db_handle_t **arg1 = (switch_cache_db_handle_t **) 0 ; @@ -10560,11 +10313,6 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_cache_db_persistant_execute_trans(void } -SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_detach() { - switch_cache_db_detach(); -} - - SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_core_debug_level() { unsigned long jresult ; uint32_t result; @@ -10616,6 +10364,60 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_default_ptime(char * jarg1, u } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_add_registration(char * jarg1, char * jarg2, char * jarg3, char * jarg4, unsigned long jarg5, char * jarg6, char * jarg7, char * jarg8) { + int jresult ; + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + uint32_t arg5 ; + char *arg6 = (char *) 0 ; + char *arg7 = (char *) 0 ; + char *arg8 = (char *) 0 ; + switch_status_t result; + + arg1 = (char *)jarg1; + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + arg4 = (char *)jarg4; + arg5 = (uint32_t)jarg5; + arg6 = (char *)jarg6; + arg7 = (char *)jarg7; + arg8 = (char *)jarg8; + result = (switch_status_t)switch_core_add_registration((char const *)arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4,arg5,(char const *)arg6,(char const *)arg7,(char const *)arg8); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_del_registration(char * jarg1, char * jarg2, char * jarg3) { + int jresult ; + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + switch_status_t result; + + arg1 = (char *)jarg1; + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + result = (switch_status_t)switch_core_del_registration((char const *)arg1,(char const *)arg2,(char const *)arg3); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_expire_registration(int jarg1) { + int jresult ; + int arg1 ; + switch_status_t result; + + arg1 = (int)jarg1; + result = (switch_status_t)switch_core_expire_registration(arg1); + jresult = result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_module_name_set(void * jarg1, char * jarg2) { switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ; char *arg2 = (char *) 0 ; @@ -25728,6 +25530,18 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_change_sln_volume(void * jarg1, unsign } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_change_sln_volume_granular(void * jarg1, unsigned long jarg2, int jarg3) { + int16_t *arg1 = (int16_t *) 0 ; + uint32_t arg2 ; + int32_t arg3 ; + + arg1 = (int16_t *)jarg1; + arg2 = (uint32_t)jarg2; + arg3 = (int32_t)jarg3; + switch_change_sln_volume_granular(arg1,arg2,arg3); +} + + SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_merge_sln(void * jarg1, unsigned long jarg2, void * jarg3, unsigned long jarg4) { unsigned long jresult ; int16_t *arg1 = (int16_t *) 0 ; @@ -28723,13 +28537,14 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_rtp_activate_rtcp(void * jarg1, int jar } -SWIGEXPORT int SWIGSTDCALL CSharp_switch_rtp_activate_jitter_buffer(void * jarg1, unsigned long jarg2, unsigned long jarg3, unsigned long jarg4, unsigned long jarg5) { +SWIGEXPORT int SWIGSTDCALL CSharp_switch_rtp_activate_jitter_buffer(void * jarg1, unsigned long jarg2, unsigned long jarg3, unsigned long jarg4, unsigned long jarg5, unsigned long jarg6) { int jresult ; switch_rtp_t *arg1 = (switch_rtp_t *) 0 ; uint32_t arg2 ; uint32_t arg3 ; uint32_t arg4 ; uint32_t arg5 ; + uint32_t arg6 ; switch_status_t result; arg1 = (switch_rtp_t *)jarg1; @@ -28737,7 +28552,8 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_rtp_activate_jitter_buffer(void * jarg1 arg3 = (uint32_t)jarg3; arg4 = (uint32_t)jarg4; arg5 = (uint32_t)jarg5; - result = (switch_status_t)switch_rtp_activate_jitter_buffer(arg1,arg2,arg3,arg4,arg5); + arg6 = (uint32_t)jarg6; + result = (switch_status_t)switch_rtp_activate_jitter_buffer(arg1,arg2,arg3,arg4,arg5,arg6); jresult = result; return jresult; } @@ -29121,6 +28937,16 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_set_telephony_recv_event(void * ja } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_set_recv_pt(void * jarg1, unsigned char jarg2) { + switch_rtp_t *arg1 = (switch_rtp_t *) 0 ; + switch_payload_t arg2 ; + + arg1 = (switch_rtp_t *)jarg1; + arg2 = (switch_payload_t)jarg2; + switch_rtp_set_recv_pt(arg1,arg2); +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_set_cng_pt(void * jarg1, unsigned char jarg2) { switch_rtp_t *arg1 = (switch_rtp_t *) 0 ; switch_payload_t arg2 ; @@ -32587,6 +32413,30 @@ SWIGEXPORT void SWIGSTDCALL CSharp_consoleCleanLog(char * jarg1) { } +SWIGEXPORT unsigned int SWIGSTDCALL CSharp_email(char * jarg1, char * jarg2, char * jarg3, char * jarg4, char * jarg5, char * jarg6, char * jarg7) { + unsigned int jresult ; + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) NULL ; + char *arg4 = (char *) NULL ; + char *arg5 = (char *) NULL ; + char *arg6 = (char *) NULL ; + char *arg7 = (char *) NULL ; + bool result; + + arg1 = (char *)jarg1; + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + arg4 = (char *)jarg4; + arg5 = (char *)jarg5; + arg6 = (char *)jarg6; + arg7 = (char *)jarg7; + result = (bool)email(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + jresult = result; + return jresult; +} + + SWIGEXPORT void * SWIGSTDCALL CSharp_new_IvrMenu(void * jarg1, char * jarg2, char * jarg3, char * jarg4, char * jarg5, char * jarg6, char * jarg7, char * jarg8, char * jarg9, char * jarg10, int jarg11, int jarg12, int jarg13, int jarg14, int jarg15, int jarg16) { void * jresult ; IVRMenu *arg1 = (IVRMenu *) 0 ; diff --git a/src/mod/languages/mod_managed/freeswitch_wrap.cxx b/src/mod/languages/mod_managed/freeswitch_wrap.cxx index 71e9f99819..72dd0cb45e 100644 --- a/src/mod/languages/mod_managed/freeswitch_wrap.cxx +++ b/src/mod/languages/mod_managed/freeswitch_wrap.cxx @@ -7473,6 +7473,42 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_switch_core_get_variable(char * jarg1) { } +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_core_get_variable_dup(char * jarg1) { + char * jresult ; + char *arg1 = (char *) 0 ; + char *result = 0 ; + + arg1 = (char *)jarg1; + result = (char *)switch_core_get_variable_dup((char const *)arg1); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_core_get_variable_pdup(char * jarg1, void * jarg2) { + char * jresult ; + char *arg1 = (char *) 0 ; + switch_memory_pool_t *arg2 = (switch_memory_pool_t *) 0 ; + char *result = 0 ; + + arg1 = (char *)jarg1; + arg2 = (switch_memory_pool_t *)jarg2; + result = (char *)switch_core_get_variable_pdup((char const *)arg1,arg2); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_core_get_hostname() { + char * jresult ; + char *result = 0 ; + + result = (char *)switch_core_get_hostname(); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_set_variable(char * jarg1, char * jarg2) { char *arg1 = (char *) 0 ; char *arg2 = (char *) 0 ; @@ -10371,290 +10407,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_cache_db_connection_options_t(v } -SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_handle_t_name_set(void * jarg1, char * jarg2) { - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - char *arg2 ; - - arg1 = (switch_cache_db_handle_t *)jarg1; - arg2 = (char *)jarg2; - { - if (arg2) strncpy((char *)arg1->name, (const char *)arg2, 256); - else arg1->name[0] = 0; - } -} - - -SWIGEXPORT char * SWIGSTDCALL CSharp_switch_cache_db_handle_t_name_get(void * jarg1) { - char * jresult ; - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - char *result = 0 ; - - arg1 = (switch_cache_db_handle_t *)jarg1; - result = (char *)(char *) ((arg1)->name); - jresult = SWIG_csharp_string_callback((const char *)result); - return jresult; -} - - -SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_handle_t_type_set(void * jarg1, int jarg2) { - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - switch_cache_db_handle_type_t arg2 ; - - arg1 = (switch_cache_db_handle_t *)jarg1; - arg2 = (switch_cache_db_handle_type_t)jarg2; - if (arg1) (arg1)->type = arg2; - -} - - -SWIGEXPORT int SWIGSTDCALL CSharp_switch_cache_db_handle_t_type_get(void * jarg1) { - int jresult ; - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - switch_cache_db_handle_type_t result; - - arg1 = (switch_cache_db_handle_t *)jarg1; - result = (switch_cache_db_handle_type_t) ((arg1)->type); - jresult = result; - return jresult; -} - - -SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_handle_t_native_handle_set(void * jarg1, void * jarg2) { - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - switch_cache_db_native_handle_t *arg2 = (switch_cache_db_native_handle_t *) 0 ; - - arg1 = (switch_cache_db_handle_t *)jarg1; - arg2 = (switch_cache_db_native_handle_t *)jarg2; - if (arg1) (arg1)->native_handle = *arg2; - -} - - -SWIGEXPORT void * SWIGSTDCALL CSharp_switch_cache_db_handle_t_native_handle_get(void * jarg1) { - void * jresult ; - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - switch_cache_db_native_handle_t *result = 0 ; - - arg1 = (switch_cache_db_handle_t *)jarg1; - result = (switch_cache_db_native_handle_t *)& ((arg1)->native_handle); - jresult = (void *)result; - return jresult; -} - - -SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_handle_t_last_used_set(void * jarg1, void * jarg2) { - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - time_t arg2 ; - time_t *argp2 ; - - arg1 = (switch_cache_db_handle_t *)jarg1; - argp2 = (time_t *)jarg2; - if (!argp2) { - SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null time_t", 0); - return ; - } - arg2 = *argp2; - if (arg1) (arg1)->last_used = arg2; - -} - - -SWIGEXPORT void * SWIGSTDCALL CSharp_switch_cache_db_handle_t_last_used_get(void * jarg1) { - void * jresult ; - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - time_t result; - - arg1 = (switch_cache_db_handle_t *)jarg1; - result = ((arg1)->last_used); - jresult = new time_t((time_t &)result); - return jresult; -} - - -SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_handle_t_mutex_set(void * jarg1, void * jarg2) { - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - switch_mutex_t *arg2 = (switch_mutex_t *) 0 ; - - arg1 = (switch_cache_db_handle_t *)jarg1; - arg2 = (switch_mutex_t *)jarg2; - if (arg1) (arg1)->mutex = arg2; - -} - - -SWIGEXPORT void * SWIGSTDCALL CSharp_switch_cache_db_handle_t_mutex_get(void * jarg1) { - void * jresult ; - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - switch_mutex_t *result = 0 ; - - arg1 = (switch_cache_db_handle_t *)jarg1; - result = (switch_mutex_t *) ((arg1)->mutex); - jresult = (void *)result; - return jresult; -} - - -SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_handle_t_io_mutex_set(void * jarg1, void * jarg2) { - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - switch_mutex_t *arg2 = (switch_mutex_t *) 0 ; - - arg1 = (switch_cache_db_handle_t *)jarg1; - arg2 = (switch_mutex_t *)jarg2; - if (arg1) (arg1)->io_mutex = arg2; - -} - - -SWIGEXPORT void * SWIGSTDCALL CSharp_switch_cache_db_handle_t_io_mutex_get(void * jarg1) { - void * jresult ; - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - switch_mutex_t *result = 0 ; - - arg1 = (switch_cache_db_handle_t *)jarg1; - result = (switch_mutex_t *) ((arg1)->io_mutex); - jresult = (void *)result; - return jresult; -} - - -SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_handle_t_pool_set(void * jarg1, void * jarg2) { - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - switch_memory_pool_t *arg2 = (switch_memory_pool_t *) 0 ; - - arg1 = (switch_cache_db_handle_t *)jarg1; - arg2 = (switch_memory_pool_t *)jarg2; - if (arg1) (arg1)->pool = arg2; - -} - - -SWIGEXPORT void * SWIGSTDCALL CSharp_switch_cache_db_handle_t_pool_get(void * jarg1) { - void * jresult ; - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - switch_memory_pool_t *result = 0 ; - - arg1 = (switch_cache_db_handle_t *)jarg1; - result = (switch_memory_pool_t *) ((arg1)->pool); - jresult = (void *)result; - return jresult; -} - - -SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_handle_t_flags_set(void * jarg1, int jarg2) { - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - int32_t arg2 ; - - arg1 = (switch_cache_db_handle_t *)jarg1; - arg2 = (int32_t)jarg2; - if (arg1) (arg1)->flags = arg2; - -} - - -SWIGEXPORT int SWIGSTDCALL CSharp_switch_cache_db_handle_t_flags_get(void * jarg1) { - int jresult ; - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - int32_t result; - - arg1 = (switch_cache_db_handle_t *)jarg1; - result = (int32_t) ((arg1)->flags); - jresult = result; - return jresult; -} - - -SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_handle_t_hash_set(void * jarg1, unsigned long jarg2) { - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - unsigned long arg2 ; - - arg1 = (switch_cache_db_handle_t *)jarg1; - arg2 = (unsigned long)jarg2; - if (arg1) (arg1)->hash = arg2; - -} - - -SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_cache_db_handle_t_hash_get(void * jarg1) { - unsigned long jresult ; - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - unsigned long result; - - arg1 = (switch_cache_db_handle_t *)jarg1; - result = (unsigned long) ((arg1)->hash); - jresult = (unsigned long)result; - return jresult; -} - - -SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_handle_t_creator_set(void * jarg1, char * jarg2) { - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - char *arg2 ; - - arg1 = (switch_cache_db_handle_t *)jarg1; - arg2 = (char *)jarg2; - { - if (arg2) strncpy((char *)arg1->creator, (const char *)arg2, 256); - else arg1->creator[0] = 0; - } -} - - -SWIGEXPORT char * SWIGSTDCALL CSharp_switch_cache_db_handle_t_creator_get(void * jarg1) { - char * jresult ; - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - char *result = 0 ; - - arg1 = (switch_cache_db_handle_t *)jarg1; - result = (char *)(char *) ((arg1)->creator); - jresult = SWIG_csharp_string_callback((const char *)result); - return jresult; -} - - -SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_handle_t_last_user_set(void * jarg1, char * jarg2) { - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - char *arg2 ; - - arg1 = (switch_cache_db_handle_t *)jarg1; - arg2 = (char *)jarg2; - { - if (arg2) strncpy((char *)arg1->last_user, (const char *)arg2, 256); - else arg1->last_user[0] = 0; - } -} - - -SWIGEXPORT char * SWIGSTDCALL CSharp_switch_cache_db_handle_t_last_user_get(void * jarg1) { - char * jresult ; - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - char *result = 0 ; - - arg1 = (switch_cache_db_handle_t *)jarg1; - result = (char *)(char *) ((arg1)->last_user); - jresult = SWIG_csharp_string_callback((const char *)result); - return jresult; -} - - -SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_cache_db_handle_t() { - void * jresult ; - switch_cache_db_handle_t *result = 0 ; - - result = (switch_cache_db_handle_t *)new switch_cache_db_handle_t(); - jresult = (void *)result; - return jresult; -} - - -SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_cache_db_handle_t(void * jarg1) { - switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; - - arg1 = (switch_cache_db_handle_t *)jarg1; - delete arg1; - -} - - SWIGEXPORT char * SWIGSTDCALL CSharp_switch_cache_db_type_name(int jarg1) { char * jresult ; switch_cache_db_handle_type_t arg1 ; @@ -10667,6 +10419,18 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_switch_cache_db_type_name(int jarg1) { } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_cache_db_get_type(void * jarg1) { + int jresult ; + switch_cache_db_handle_t *arg1 = (switch_cache_db_handle_t *) 0 ; + switch_cache_db_handle_type_t result; + + arg1 = (switch_cache_db_handle_t *)jarg1; + result = (switch_cache_db_handle_type_t)switch_cache_db_get_type(arg1); + jresult = result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_dismiss_db_handle(void * jarg1) { switch_cache_db_handle_t **arg1 = (switch_cache_db_handle_t **) 0 ; @@ -10683,14 +10447,6 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_release_db_handle(void * jarg } -SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_destroy_db_handle(void * jarg1) { - switch_cache_db_handle_t **arg1 = (switch_cache_db_handle_t **) 0 ; - - arg1 = (switch_cache_db_handle_t **)jarg1; - switch_cache_db_destroy_db_handle(arg1); -} - - SWIGEXPORT int SWIGSTDCALL CSharp__switch_cache_db_get_db_handle(void * jarg1, int jarg2, void * jarg3, char * jarg4, char * jarg5, int jarg6) { int jresult ; switch_cache_db_handle_t **arg1 = (switch_cache_db_handle_t **) 0 ; @@ -10857,11 +10613,6 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_cache_db_persistant_execute_trans(void } -SWIGEXPORT void SWIGSTDCALL CSharp_switch_cache_db_detach() { - switch_cache_db_detach(); -} - - SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_core_debug_level() { unsigned long jresult ; uint32_t result; @@ -10913,6 +10664,60 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_default_ptime(char * jarg1, u } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_add_registration(char * jarg1, char * jarg2, char * jarg3, char * jarg4, unsigned long jarg5, char * jarg6, char * jarg7, char * jarg8) { + int jresult ; + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + uint32_t arg5 ; + char *arg6 = (char *) 0 ; + char *arg7 = (char *) 0 ; + char *arg8 = (char *) 0 ; + switch_status_t result; + + arg1 = (char *)jarg1; + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + arg4 = (char *)jarg4; + arg5 = (uint32_t)jarg5; + arg6 = (char *)jarg6; + arg7 = (char *)jarg7; + arg8 = (char *)jarg8; + result = (switch_status_t)switch_core_add_registration((char const *)arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4,arg5,(char const *)arg6,(char const *)arg7,(char const *)arg8); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_del_registration(char * jarg1, char * jarg2, char * jarg3) { + int jresult ; + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + switch_status_t result; + + arg1 = (char *)jarg1; + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + result = (switch_status_t)switch_core_del_registration((char const *)arg1,(char const *)arg2,(char const *)arg3); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_expire_registration(int jarg1) { + int jresult ; + int arg1 ; + switch_status_t result; + + arg1 = (int)jarg1; + result = (switch_status_t)switch_core_expire_registration(arg1); + jresult = result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_module_name_set(void * jarg1, char * jarg2) { switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ; char *arg2 = (char *) 0 ; @@ -26411,6 +26216,18 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_change_sln_volume(void * jarg1, unsign } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_change_sln_volume_granular(void * jarg1, unsigned long jarg2, int jarg3) { + int16_t *arg1 = (int16_t *) 0 ; + uint32_t arg2 ; + int32_t arg3 ; + + arg1 = (int16_t *)jarg1; + arg2 = (uint32_t)jarg2; + arg3 = (int32_t)jarg3; + switch_change_sln_volume_granular(arg1,arg2,arg3); +} + + SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_merge_sln(void * jarg1, unsigned long jarg2, void * jarg3, unsigned long jarg4) { unsigned long jresult ; int16_t *arg1 = (int16_t *) 0 ; @@ -29431,13 +29248,14 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_rtp_activate_rtcp(void * jarg1, int jar } -SWIGEXPORT int SWIGSTDCALL CSharp_switch_rtp_activate_jitter_buffer(void * jarg1, unsigned long jarg2, unsigned long jarg3, unsigned long jarg4, unsigned long jarg5) { +SWIGEXPORT int SWIGSTDCALL CSharp_switch_rtp_activate_jitter_buffer(void * jarg1, unsigned long jarg2, unsigned long jarg3, unsigned long jarg4, unsigned long jarg5, unsigned long jarg6) { int jresult ; switch_rtp_t *arg1 = (switch_rtp_t *) 0 ; uint32_t arg2 ; uint32_t arg3 ; uint32_t arg4 ; uint32_t arg5 ; + uint32_t arg6 ; switch_status_t result; arg1 = (switch_rtp_t *)jarg1; @@ -29445,7 +29263,8 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_rtp_activate_jitter_buffer(void * jarg1 arg3 = (uint32_t)jarg3; arg4 = (uint32_t)jarg4; arg5 = (uint32_t)jarg5; - result = (switch_status_t)switch_rtp_activate_jitter_buffer(arg1,arg2,arg3,arg4,arg5); + arg6 = (uint32_t)jarg6; + result = (switch_status_t)switch_rtp_activate_jitter_buffer(arg1,arg2,arg3,arg4,arg5,arg6); jresult = result; return jresult; } @@ -29829,6 +29648,16 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_set_telephony_recv_event(void * ja } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_set_recv_pt(void * jarg1, unsigned char jarg2) { + switch_rtp_t *arg1 = (switch_rtp_t *) 0 ; + switch_payload_t arg2 ; + + arg1 = (switch_rtp_t *)jarg1; + arg2 = (switch_payload_t)jarg2; + switch_rtp_set_recv_pt(arg1,arg2); +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_rtp_set_cng_pt(void * jarg1, unsigned char jarg2) { switch_rtp_t *arg1 = (switch_rtp_t *) 0 ; switch_payload_t arg2 ; diff --git a/src/mod/languages/mod_managed/managed/swig.2010.cs b/src/mod/languages/mod_managed/managed/swig.2010.cs index 61c0a4e462..eb6d93531c 100644 --- a/src/mod/languages/mod_managed/managed/swig.2010.cs +++ b/src/mod/languages/mod_managed/managed/swig.2010.cs @@ -1394,6 +1394,21 @@ public class freeswitch { return ret; } + public static string switch_core_get_variable_dup(string varname) { + string ret = freeswitchPINVOKE.switch_core_get_variable_dup(varname); + return ret; + } + + public static string switch_core_get_variable_pdup(string varname, SWIGTYPE_p_apr_pool_t pool) { + string ret = freeswitchPINVOKE.switch_core_get_variable_pdup(varname, SWIGTYPE_p_apr_pool_t.getCPtr(pool)); + return ret; + } + + public static string switch_core_get_hostname() { + string ret = freeswitchPINVOKE.switch_core_get_hostname(); + return ret; + } + public static void switch_core_set_variable(string varname, string value) { freeswitchPINVOKE.switch_core_set_variable(varname, value); } @@ -2336,40 +2351,41 @@ public class freeswitch { return ret; } - public static void switch_cache_db_dismiss_db_handle(SWIGTYPE_p_p_switch_cache_db_handle_t dbh) { - freeswitchPINVOKE.switch_cache_db_dismiss_db_handle(SWIGTYPE_p_p_switch_cache_db_handle_t.getCPtr(dbh)); - } - - public static void switch_cache_db_release_db_handle(SWIGTYPE_p_p_switch_cache_db_handle_t dbh) { - freeswitchPINVOKE.switch_cache_db_release_db_handle(SWIGTYPE_p_p_switch_cache_db_handle_t.getCPtr(dbh)); - } - - public static void switch_cache_db_destroy_db_handle(SWIGTYPE_p_p_switch_cache_db_handle_t dbh) { - freeswitchPINVOKE.switch_cache_db_destroy_db_handle(SWIGTYPE_p_p_switch_cache_db_handle_t.getCPtr(dbh)); - } - - public static switch_status_t _switch_cache_db_get_db_handle(SWIGTYPE_p_p_switch_cache_db_handle_t dbh, switch_cache_db_handle_type_t type, switch_cache_db_connection_options_t connection_options, string file, string func, int line) { - switch_status_t ret = (switch_status_t)freeswitchPINVOKE._switch_cache_db_get_db_handle(SWIGTYPE_p_p_switch_cache_db_handle_t.getCPtr(dbh), (int)type, switch_cache_db_connection_options_t.getCPtr(connection_options), file, func, line); + public static switch_cache_db_handle_type_t switch_cache_db_get_type(SWIGTYPE_p_switch_cache_db_handle dbh) { + switch_cache_db_handle_type_t ret = (switch_cache_db_handle_type_t)freeswitchPINVOKE.switch_cache_db_get_type(SWIGTYPE_p_switch_cache_db_handle.getCPtr(dbh)); return ret; } - public static string switch_cache_db_execute_sql2str(switch_cache_db_handle_t dbh, string sql, string str, uint len, ref string err) { - string ret = freeswitchPINVOKE.switch_cache_db_execute_sql2str(switch_cache_db_handle_t.getCPtr(dbh), sql, str, len, ref err); + public static void switch_cache_db_dismiss_db_handle(SWIGTYPE_p_p_switch_cache_db_handle dbh) { + freeswitchPINVOKE.switch_cache_db_dismiss_db_handle(SWIGTYPE_p_p_switch_cache_db_handle.getCPtr(dbh)); + } + + public static void switch_cache_db_release_db_handle(SWIGTYPE_p_p_switch_cache_db_handle dbh) { + freeswitchPINVOKE.switch_cache_db_release_db_handle(SWIGTYPE_p_p_switch_cache_db_handle.getCPtr(dbh)); + } + + public static switch_status_t _switch_cache_db_get_db_handle(SWIGTYPE_p_p_switch_cache_db_handle dbh, switch_cache_db_handle_type_t type, switch_cache_db_connection_options_t connection_options, string file, string func, int line) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE._switch_cache_db_get_db_handle(SWIGTYPE_p_p_switch_cache_db_handle.getCPtr(dbh), (int)type, switch_cache_db_connection_options_t.getCPtr(connection_options), file, func, line); return ret; } - public static switch_status_t switch_cache_db_execute_sql(switch_cache_db_handle_t dbh, string sql, ref string err) { - switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_cache_db_execute_sql(switch_cache_db_handle_t.getCPtr(dbh), sql, ref err); + public static string switch_cache_db_execute_sql2str(SWIGTYPE_p_switch_cache_db_handle dbh, string sql, string str, uint len, ref string err) { + string ret = freeswitchPINVOKE.switch_cache_db_execute_sql2str(SWIGTYPE_p_switch_cache_db_handle.getCPtr(dbh), sql, str, len, ref err); return ret; } - public static switch_status_t switch_cache_db_execute_sql_callback(switch_cache_db_handle_t dbh, string sql, SWIGTYPE_p_f_p_void_int_p_p_char_p_p_char__int callback, SWIGTYPE_p_void pdata, ref string err) { - switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_cache_db_execute_sql_callback(switch_cache_db_handle_t.getCPtr(dbh), sql, SWIGTYPE_p_f_p_void_int_p_p_char_p_p_char__int.getCPtr(callback), SWIGTYPE_p_void.getCPtr(pdata), ref err); + public static switch_status_t switch_cache_db_execute_sql(SWIGTYPE_p_switch_cache_db_handle dbh, string sql, ref string err) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_cache_db_execute_sql(SWIGTYPE_p_switch_cache_db_handle.getCPtr(dbh), sql, ref err); return ret; } - public static int switch_cache_db_affected_rows(switch_cache_db_handle_t dbh) { - int ret = freeswitchPINVOKE.switch_cache_db_affected_rows(switch_cache_db_handle_t.getCPtr(dbh)); + public static switch_status_t switch_cache_db_execute_sql_callback(SWIGTYPE_p_switch_cache_db_handle dbh, string sql, SWIGTYPE_p_f_p_void_int_p_p_char_p_p_char__int callback, SWIGTYPE_p_void pdata, ref string err) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_cache_db_execute_sql_callback(SWIGTYPE_p_switch_cache_db_handle.getCPtr(dbh), sql, SWIGTYPE_p_f_p_void_int_p_p_char_p_p_char__int.getCPtr(callback), SWIGTYPE_p_void.getCPtr(pdata), ref err); + return ret; + } + + public static int switch_cache_db_affected_rows(SWIGTYPE_p_switch_cache_db_handle dbh) { + int ret = freeswitchPINVOKE.switch_cache_db_affected_rows(SWIGTYPE_p_switch_cache_db_handle.getCPtr(dbh)); return ret; } @@ -2377,30 +2393,26 @@ public class freeswitch { freeswitchPINVOKE.switch_cache_db_status(switch_stream_handle.getCPtr(stream)); } - public static switch_status_t _switch_core_db_handle(SWIGTYPE_p_p_switch_cache_db_handle_t dbh, string file, string func, int line) { - switch_status_t ret = (switch_status_t)freeswitchPINVOKE._switch_core_db_handle(SWIGTYPE_p_p_switch_cache_db_handle_t.getCPtr(dbh), file, func, line); + public static switch_status_t _switch_core_db_handle(SWIGTYPE_p_p_switch_cache_db_handle dbh, string file, string func, int line) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE._switch_core_db_handle(SWIGTYPE_p_p_switch_cache_db_handle.getCPtr(dbh), file, func, line); return ret; } - public static switch_bool_t switch_cache_db_test_reactive(switch_cache_db_handle_t db, string test_sql, string drop_sql, string reactive_sql) { - switch_bool_t ret = (switch_bool_t)freeswitchPINVOKE.switch_cache_db_test_reactive(switch_cache_db_handle_t.getCPtr(db), test_sql, drop_sql, reactive_sql); + public static switch_bool_t switch_cache_db_test_reactive(SWIGTYPE_p_switch_cache_db_handle db, string test_sql, string drop_sql, string reactive_sql) { + switch_bool_t ret = (switch_bool_t)freeswitchPINVOKE.switch_cache_db_test_reactive(SWIGTYPE_p_switch_cache_db_handle.getCPtr(db), test_sql, drop_sql, reactive_sql); return ret; } - public static switch_status_t switch_cache_db_persistant_execute(switch_cache_db_handle_t dbh, string sql, uint retries) { - switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_cache_db_persistant_execute(switch_cache_db_handle_t.getCPtr(dbh), sql, retries); + public static switch_status_t switch_cache_db_persistant_execute(SWIGTYPE_p_switch_cache_db_handle dbh, string sql, uint retries) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_cache_db_persistant_execute(SWIGTYPE_p_switch_cache_db_handle.getCPtr(dbh), sql, retries); return ret; } - public static switch_status_t switch_cache_db_persistant_execute_trans(switch_cache_db_handle_t dbh, string sql, uint retries) { - switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_cache_db_persistant_execute_trans(switch_cache_db_handle_t.getCPtr(dbh), sql, retries); + public static switch_status_t switch_cache_db_persistant_execute_trans(SWIGTYPE_p_switch_cache_db_handle dbh, string sql, uint retries) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_cache_db_persistant_execute_trans(SWIGTYPE_p_switch_cache_db_handle.getCPtr(dbh), sql, retries); return ret; } - public static void switch_cache_db_detach() { - freeswitchPINVOKE.switch_cache_db_detach(); - } - public static uint switch_core_debug_level() { uint ret = freeswitchPINVOKE.switch_core_debug_level(); return ret; @@ -2425,6 +2437,21 @@ public class freeswitch { return ret; } + public static switch_status_t switch_core_add_registration(string user, string realm, string token, string url, uint expires, string network_ip, string network_port, string network_proto) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_add_registration(user, realm, token, url, expires, network_ip, network_port, network_proto); + return ret; + } + + public static switch_status_t switch_core_del_registration(string user, string realm, string token) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_del_registration(user, realm, token); + return ret; + } + + public static switch_status_t switch_core_expire_registration(int force) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_expire_registration(force); + return ret; + } + public static switch_status_t switch_loadable_module_init(switch_bool_t autoload) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_loadable_module_init((int)autoload); return ret; @@ -3984,6 +4011,10 @@ public class freeswitch { freeswitchPINVOKE.switch_change_sln_volume(SWIGTYPE_p_short.getCPtr(data), samples, vol); } + public static void switch_change_sln_volume_granular(SWIGTYPE_p_short data, uint samples, int vol) { + freeswitchPINVOKE.switch_change_sln_volume_granular(SWIGTYPE_p_short.getCPtr(data), samples, vol); + } + public static uint switch_merge_sln(SWIGTYPE_p_short data, uint samples, SWIGTYPE_p_short other_data, uint other_samples) { uint ret = freeswitchPINVOKE.switch_merge_sln(SWIGTYPE_p_short.getCPtr(data), samples, SWIGTYPE_p_short.getCPtr(other_data), other_samples); return ret; @@ -4729,8 +4760,8 @@ public class freeswitch { return ret; } - public static switch_status_t switch_rtp_activate_jitter_buffer(SWIGTYPE_p_switch_rtp rtp_session, uint queue_frames, uint max_queue_frames, uint samples_per_packet, uint samples_per_second) { - switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_rtp_activate_jitter_buffer(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), queue_frames, max_queue_frames, samples_per_packet, samples_per_second); + public static switch_status_t switch_rtp_activate_jitter_buffer(SWIGTYPE_p_switch_rtp rtp_session, uint queue_frames, uint max_queue_frames, uint samples_per_packet, uint samples_per_second, uint max_drift) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_rtp_activate_jitter_buffer(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), queue_frames, max_queue_frames, samples_per_packet, samples_per_second, max_drift); return ret; } @@ -4867,6 +4898,10 @@ public class freeswitch { freeswitchPINVOKE.switch_rtp_set_telephony_recv_event(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), te); } + public static void switch_rtp_set_recv_pt(SWIGTYPE_p_switch_rtp rtp_session, byte pt) { + freeswitchPINVOKE.switch_rtp_set_recv_pt(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), pt); + } + public static void switch_rtp_set_cng_pt(SWIGTYPE_p_switch_rtp rtp_session, byte pt) { freeswitchPINVOKE.switch_rtp_set_cng_pt(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), pt); } @@ -5374,6 +5409,11 @@ public class freeswitch { freeswitchPINVOKE.consoleCleanLog(msg); } + public static bool email(string to, string from, string headers, string body, string file, string convert_cmd, string convert_ext) { + bool ret = freeswitchPINVOKE.email(to, from, headers, body, file, convert_cmd, convert_ext); + return ret; + } + public static void console_log(string level_str, string msg) { freeswitchPINVOKE.console_log(level_str, msg); } @@ -7578,6 +7618,15 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_get_variable")] public static extern string switch_core_get_variable(string jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_get_variable_dup")] + public static extern string switch_core_get_variable_dup(string jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_get_variable_pdup")] + public static extern string switch_core_get_variable_pdup(string jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_get_hostname")] + public static extern string switch_core_get_hostname(); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_set_variable")] public static extern void switch_core_set_variable(string jarg1, string jarg2); @@ -8226,90 +8275,18 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_delete_switch_cache_db_connection_options_t")] public static extern void delete_switch_cache_db_connection_options_t(HandleRef jarg1); - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_name_set")] - public static extern void switch_cache_db_handle_t_name_set(HandleRef jarg1, string jarg2); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_name_get")] - public static extern string switch_cache_db_handle_t_name_get(HandleRef jarg1); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_type_set")] - public static extern void switch_cache_db_handle_t_type_set(HandleRef jarg1, int jarg2); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_type_get")] - public static extern int switch_cache_db_handle_t_type_get(HandleRef jarg1); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_native_handle_set")] - public static extern void switch_cache_db_handle_t_native_handle_set(HandleRef jarg1, HandleRef jarg2); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_native_handle_get")] - public static extern IntPtr switch_cache_db_handle_t_native_handle_get(HandleRef jarg1); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_last_used_set")] - public static extern void switch_cache_db_handle_t_last_used_set(HandleRef jarg1, HandleRef jarg2); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_last_used_get")] - public static extern IntPtr switch_cache_db_handle_t_last_used_get(HandleRef jarg1); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_mutex_set")] - public static extern void switch_cache_db_handle_t_mutex_set(HandleRef jarg1, HandleRef jarg2); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_mutex_get")] - public static extern IntPtr switch_cache_db_handle_t_mutex_get(HandleRef jarg1); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_io_mutex_set")] - public static extern void switch_cache_db_handle_t_io_mutex_set(HandleRef jarg1, HandleRef jarg2); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_io_mutex_get")] - public static extern IntPtr switch_cache_db_handle_t_io_mutex_get(HandleRef jarg1); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_pool_set")] - public static extern void switch_cache_db_handle_t_pool_set(HandleRef jarg1, HandleRef jarg2); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_pool_get")] - public static extern IntPtr switch_cache_db_handle_t_pool_get(HandleRef jarg1); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_flags_set")] - public static extern void switch_cache_db_handle_t_flags_set(HandleRef jarg1, int jarg2); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_flags_get")] - public static extern int switch_cache_db_handle_t_flags_get(HandleRef jarg1); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_hash_set")] - public static extern void switch_cache_db_handle_t_hash_set(HandleRef jarg1, uint jarg2); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_hash_get")] - public static extern uint switch_cache_db_handle_t_hash_get(HandleRef jarg1); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_creator_set")] - public static extern void switch_cache_db_handle_t_creator_set(HandleRef jarg1, string jarg2); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_creator_get")] - public static extern string switch_cache_db_handle_t_creator_get(HandleRef jarg1); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_last_user_set")] - public static extern void switch_cache_db_handle_t_last_user_set(HandleRef jarg1, string jarg2); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_last_user_get")] - public static extern string switch_cache_db_handle_t_last_user_get(HandleRef jarg1); - - [DllImport("mod_managed", EntryPoint="CSharp_new_switch_cache_db_handle_t")] - public static extern IntPtr new_switch_cache_db_handle_t(); - - [DllImport("mod_managed", EntryPoint="CSharp_delete_switch_cache_db_handle_t")] - public static extern void delete_switch_cache_db_handle_t(HandleRef jarg1); - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_type_name")] public static extern string switch_cache_db_type_name(int jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_get_type")] + public static extern int switch_cache_db_get_type(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_dismiss_db_handle")] public static extern void switch_cache_db_dismiss_db_handle(HandleRef jarg1); [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_release_db_handle")] public static extern void switch_cache_db_release_db_handle(HandleRef jarg1); - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_destroy_db_handle")] - public static extern void switch_cache_db_destroy_db_handle(HandleRef jarg1); - [DllImport("mod_managed", EntryPoint="CSharp__switch_cache_db_get_db_handle")] public static extern int _switch_cache_db_get_db_handle(HandleRef jarg1, int jarg2, HandleRef jarg3, string jarg4, string jarg5, int jarg6); @@ -8340,9 +8317,6 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_persistant_execute_trans")] public static extern int switch_cache_db_persistant_execute_trans(HandleRef jarg1, string jarg2, uint jarg3); - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_detach")] - public static extern void switch_cache_db_detach(); - [DllImport("mod_managed", EntryPoint="CSharp_switch_core_debug_level")] public static extern uint switch_core_debug_level(); @@ -8358,6 +8332,15 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_default_ptime")] public static extern uint switch_default_ptime(string jarg1, uint jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_add_registration")] + public static extern int switch_core_add_registration(string jarg1, string jarg2, string jarg3, string jarg4, uint jarg5, string jarg6, string jarg7, string jarg8); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_del_registration")] + public static extern int switch_core_del_registration(string jarg1, string jarg2, string jarg3); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_expire_registration")] + public static extern int switch_core_expire_registration(int jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_loadable_module_interface_module_name_set")] public static extern void switch_loadable_module_interface_module_name_set(HandleRef jarg1, string jarg2); @@ -12051,6 +12034,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_change_sln_volume")] public static extern void switch_change_sln_volume(HandleRef jarg1, uint jarg2, int jarg3); + [DllImport("mod_managed", EntryPoint="CSharp_switch_change_sln_volume_granular")] + public static extern void switch_change_sln_volume_granular(HandleRef jarg1, uint jarg2, int jarg3); + [DllImport("mod_managed", EntryPoint="CSharp_switch_merge_sln")] public static extern uint switch_merge_sln(HandleRef jarg1, uint jarg2, HandleRef jarg3, uint jarg4); @@ -12661,7 +12647,7 @@ class freeswitchPINVOKE { public static extern int switch_rtp_activate_rtcp(HandleRef jarg1, int jarg2, ushort jarg3); [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_activate_jitter_buffer")] - public static extern int switch_rtp_activate_jitter_buffer(HandleRef jarg1, uint jarg2, uint jarg3, uint jarg4, uint jarg5); + public static extern int switch_rtp_activate_jitter_buffer(HandleRef jarg1, uint jarg2, uint jarg3, uint jarg4, uint jarg5, uint jarg6); [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_debug_jitter_buffer")] public static extern int switch_rtp_debug_jitter_buffer(HandleRef jarg1, string jarg2); @@ -12747,6 +12733,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_set_telephony_recv_event")] public static extern void switch_rtp_set_telephony_recv_event(HandleRef jarg1, byte jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_set_recv_pt")] + public static extern void switch_rtp_set_recv_pt(HandleRef jarg1, byte jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_set_cng_pt")] public static extern void switch_rtp_set_cng_pt(HandleRef jarg1, byte jarg2); @@ -13602,6 +13591,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_consoleCleanLog")] public static extern void consoleCleanLog(string jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_email")] + public static extern bool email(string jarg1, string jarg2, string jarg3, string jarg4, string jarg5, string jarg6, string jarg7); + [DllImport("mod_managed", EntryPoint="CSharp_new_IvrMenu")] public static extern IntPtr new_IvrMenu(HandleRef jarg1, string jarg2, string jarg3, string jarg4, string jarg5, string jarg6, string jarg7, string jarg8, string jarg9, string jarg10, int jarg11, int jarg12, int jarg13, int jarg14, int jarg15, int jarg16); @@ -17185,18 +17177,18 @@ namespace FreeSWITCH.Native { using System; using System.Runtime.InteropServices; -public class SWIGTYPE_p_p_switch_cache_db_handle_t { +public class SWIGTYPE_p_p_switch_cache_db_handle { private HandleRef swigCPtr; - internal SWIGTYPE_p_p_switch_cache_db_handle_t(IntPtr cPtr, bool futureUse) { + internal SWIGTYPE_p_p_switch_cache_db_handle(IntPtr cPtr, bool futureUse) { swigCPtr = new HandleRef(this, cPtr); } - protected SWIGTYPE_p_p_switch_cache_db_handle_t() { + protected SWIGTYPE_p_p_switch_cache_db_handle() { swigCPtr = new HandleRef(null, IntPtr.Zero); } - internal static HandleRef getCPtr(SWIGTYPE_p_p_switch_cache_db_handle_t obj) { + internal static HandleRef getCPtr(SWIGTYPE_p_p_switch_cache_db_handle obj) { return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; } } @@ -18205,6 +18197,36 @@ namespace FreeSWITCH.Native { using System; using System.Runtime.InteropServices; +public class SWIGTYPE_p_switch_cache_db_handle { + private HandleRef swigCPtr; + + internal SWIGTYPE_p_switch_cache_db_handle(IntPtr cPtr, bool futureUse) { + swigCPtr = new HandleRef(this, cPtr); + } + + protected SWIGTYPE_p_switch_cache_db_handle() { + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + + internal static HandleRef getCPtr(SWIGTYPE_p_switch_cache_db_handle obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } +} + +} +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.1 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace FreeSWITCH.Native { + +using System; +using System.Runtime.InteropServices; + public class SWIGTYPE_p_switch_call_cause_t { private HandleRef swigCPtr; @@ -20687,171 +20709,6 @@ public class switch_cache_db_core_db_options_t : IDisposable { namespace FreeSWITCH.Native { -using System; -using System.Runtime.InteropServices; - -public class switch_cache_db_handle_t : IDisposable { - private HandleRef swigCPtr; - protected bool swigCMemOwn; - - internal switch_cache_db_handle_t(IntPtr cPtr, bool cMemoryOwn) { - swigCMemOwn = cMemoryOwn; - swigCPtr = new HandleRef(this, cPtr); - } - - internal static HandleRef getCPtr(switch_cache_db_handle_t obj) { - return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; - } - - ~switch_cache_db_handle_t() { - Dispose(); - } - - public virtual void Dispose() { - lock(this) { - if (swigCPtr.Handle != IntPtr.Zero) { - if (swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_cache_db_handle_t(swigCPtr); - } - swigCPtr = new HandleRef(null, IntPtr.Zero); - } - GC.SuppressFinalize(this); - } - } - - public string name { - set { - freeswitchPINVOKE.switch_cache_db_handle_t_name_set(swigCPtr, value); - } - get { - string ret = freeswitchPINVOKE.switch_cache_db_handle_t_name_get(swigCPtr); - return ret; - } - } - - public switch_cache_db_handle_type_t type { - set { - freeswitchPINVOKE.switch_cache_db_handle_t_type_set(swigCPtr, (int)value); - } - get { - switch_cache_db_handle_type_t ret = (switch_cache_db_handle_type_t)freeswitchPINVOKE.switch_cache_db_handle_t_type_get(swigCPtr); - return ret; - } - } - - public switch_cache_db_native_handle_t native_handle { - set { - freeswitchPINVOKE.switch_cache_db_handle_t_native_handle_set(swigCPtr, switch_cache_db_native_handle_t.getCPtr(value)); - } - get { - IntPtr cPtr = freeswitchPINVOKE.switch_cache_db_handle_t_native_handle_get(swigCPtr); - switch_cache_db_native_handle_t ret = (cPtr == IntPtr.Zero) ? null : new switch_cache_db_native_handle_t(cPtr, false); - return ret; - } - } - - public SWIGTYPE_p_time_t last_used { - set { - freeswitchPINVOKE.switch_cache_db_handle_t_last_used_set(swigCPtr, SWIGTYPE_p_time_t.getCPtr(value)); - if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); - } - get { - SWIGTYPE_p_time_t ret = new SWIGTYPE_p_time_t(freeswitchPINVOKE.switch_cache_db_handle_t_last_used_get(swigCPtr), true); - if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); - return ret; - } - } - - public SWIGTYPE_p_switch_mutex_t mutex { - set { - freeswitchPINVOKE.switch_cache_db_handle_t_mutex_set(swigCPtr, SWIGTYPE_p_switch_mutex_t.getCPtr(value)); - } - get { - IntPtr cPtr = freeswitchPINVOKE.switch_cache_db_handle_t_mutex_get(swigCPtr); - SWIGTYPE_p_switch_mutex_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_switch_mutex_t(cPtr, false); - return ret; - } - } - - public SWIGTYPE_p_switch_mutex_t io_mutex { - set { - freeswitchPINVOKE.switch_cache_db_handle_t_io_mutex_set(swigCPtr, SWIGTYPE_p_switch_mutex_t.getCPtr(value)); - } - get { - IntPtr cPtr = freeswitchPINVOKE.switch_cache_db_handle_t_io_mutex_get(swigCPtr); - SWIGTYPE_p_switch_mutex_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_switch_mutex_t(cPtr, false); - return ret; - } - } - - public SWIGTYPE_p_apr_pool_t pool { - set { - freeswitchPINVOKE.switch_cache_db_handle_t_pool_set(swigCPtr, SWIGTYPE_p_apr_pool_t.getCPtr(value)); - } - get { - IntPtr cPtr = freeswitchPINVOKE.switch_cache_db_handle_t_pool_get(swigCPtr); - SWIGTYPE_p_apr_pool_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_apr_pool_t(cPtr, false); - return ret; - } - } - - public int flags { - set { - freeswitchPINVOKE.switch_cache_db_handle_t_flags_set(swigCPtr, value); - } - get { - int ret = freeswitchPINVOKE.switch_cache_db_handle_t_flags_get(swigCPtr); - return ret; - } - } - - public uint hash { - set { - freeswitchPINVOKE.switch_cache_db_handle_t_hash_set(swigCPtr, value); - } - get { - uint ret = freeswitchPINVOKE.switch_cache_db_handle_t_hash_get(swigCPtr); - return ret; - } - } - - public string creator { - set { - freeswitchPINVOKE.switch_cache_db_handle_t_creator_set(swigCPtr, value); - } - get { - string ret = freeswitchPINVOKE.switch_cache_db_handle_t_creator_get(swigCPtr); - return ret; - } - } - - public string last_user { - set { - freeswitchPINVOKE.switch_cache_db_handle_t_last_user_set(swigCPtr, value); - } - get { - string ret = freeswitchPINVOKE.switch_cache_db_handle_t_last_user_get(swigCPtr); - return ret; - } - } - - public switch_cache_db_handle_t() : this(freeswitchPINVOKE.new_switch_cache_db_handle_t(), true) { - } - -} - -} -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.1 - * - * Do not make changes to this file unless you know what you are doing--modify - * the SWIG interface file instead. - * ----------------------------------------------------------------------------- */ - -namespace FreeSWITCH.Native { - public enum switch_cache_db_handle_type_t { SCDB_TYPE_CORE_DB, SCDB_TYPE_ODBC @@ -24977,6 +24834,8 @@ public enum switch_event_types_t { SWITCH_EVENT_NAT, SWITCH_EVENT_RECORD_START, SWITCH_EVENT_RECORD_STOP, + SWITCH_EVENT_PLAYBACK_START, + SWITCH_EVENT_PLAYBACK_STOP, SWITCH_EVENT_CALL_UPDATE, SWITCH_EVENT_FAILURE, SWITCH_EVENT_SOCKET_DATA, diff --git a/src/mod/languages/mod_managed/managed/swig.cs b/src/mod/languages/mod_managed/managed/swig.cs index c640199353..ac472af502 100644 --- a/src/mod/languages/mod_managed/managed/swig.cs +++ b/src/mod/languages/mod_managed/managed/swig.cs @@ -1384,6 +1384,21 @@ public class freeswitch { return ret; } + public static string switch_core_get_variable_dup(string varname) { + string ret = freeswitchPINVOKE.switch_core_get_variable_dup(varname); + return ret; + } + + public static string switch_core_get_variable_pdup(string varname, SWIGTYPE_p_apr_pool_t pool) { + string ret = freeswitchPINVOKE.switch_core_get_variable_pdup(varname, SWIGTYPE_p_apr_pool_t.getCPtr(pool)); + return ret; + } + + public static string switch_core_get_hostname() { + string ret = freeswitchPINVOKE.switch_core_get_hostname(); + return ret; + } + public static void switch_core_set_variable(string varname, string value) { freeswitchPINVOKE.switch_core_set_variable(varname, value); } @@ -2326,40 +2341,41 @@ public class freeswitch { return ret; } - public static void switch_cache_db_dismiss_db_handle(SWIGTYPE_p_p_switch_cache_db_handle_t dbh) { - freeswitchPINVOKE.switch_cache_db_dismiss_db_handle(SWIGTYPE_p_p_switch_cache_db_handle_t.getCPtr(dbh)); - } - - public static void switch_cache_db_release_db_handle(SWIGTYPE_p_p_switch_cache_db_handle_t dbh) { - freeswitchPINVOKE.switch_cache_db_release_db_handle(SWIGTYPE_p_p_switch_cache_db_handle_t.getCPtr(dbh)); - } - - public static void switch_cache_db_destroy_db_handle(SWIGTYPE_p_p_switch_cache_db_handle_t dbh) { - freeswitchPINVOKE.switch_cache_db_destroy_db_handle(SWIGTYPE_p_p_switch_cache_db_handle_t.getCPtr(dbh)); - } - - public static switch_status_t _switch_cache_db_get_db_handle(SWIGTYPE_p_p_switch_cache_db_handle_t dbh, switch_cache_db_handle_type_t type, switch_cache_db_connection_options_t connection_options, string file, string func, int line) { - switch_status_t ret = (switch_status_t)freeswitchPINVOKE._switch_cache_db_get_db_handle(SWIGTYPE_p_p_switch_cache_db_handle_t.getCPtr(dbh), (int)type, switch_cache_db_connection_options_t.getCPtr(connection_options), file, func, line); + public static switch_cache_db_handle_type_t switch_cache_db_get_type(SWIGTYPE_p_switch_cache_db_handle dbh) { + switch_cache_db_handle_type_t ret = (switch_cache_db_handle_type_t)freeswitchPINVOKE.switch_cache_db_get_type(SWIGTYPE_p_switch_cache_db_handle.getCPtr(dbh)); return ret; } - public static string switch_cache_db_execute_sql2str(switch_cache_db_handle_t dbh, string sql, string str, uint len, ref string err) { - string ret = freeswitchPINVOKE.switch_cache_db_execute_sql2str(switch_cache_db_handle_t.getCPtr(dbh), sql, str, len, ref err); + public static void switch_cache_db_dismiss_db_handle(SWIGTYPE_p_p_switch_cache_db_handle dbh) { + freeswitchPINVOKE.switch_cache_db_dismiss_db_handle(SWIGTYPE_p_p_switch_cache_db_handle.getCPtr(dbh)); + } + + public static void switch_cache_db_release_db_handle(SWIGTYPE_p_p_switch_cache_db_handle dbh) { + freeswitchPINVOKE.switch_cache_db_release_db_handle(SWIGTYPE_p_p_switch_cache_db_handle.getCPtr(dbh)); + } + + public static switch_status_t _switch_cache_db_get_db_handle(SWIGTYPE_p_p_switch_cache_db_handle dbh, switch_cache_db_handle_type_t type, switch_cache_db_connection_options_t connection_options, string file, string func, int line) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE._switch_cache_db_get_db_handle(SWIGTYPE_p_p_switch_cache_db_handle.getCPtr(dbh), (int)type, switch_cache_db_connection_options_t.getCPtr(connection_options), file, func, line); return ret; } - public static switch_status_t switch_cache_db_execute_sql(switch_cache_db_handle_t dbh, string sql, ref string err) { - switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_cache_db_execute_sql(switch_cache_db_handle_t.getCPtr(dbh), sql, ref err); + public static string switch_cache_db_execute_sql2str(SWIGTYPE_p_switch_cache_db_handle dbh, string sql, string str, uint len, ref string err) { + string ret = freeswitchPINVOKE.switch_cache_db_execute_sql2str(SWIGTYPE_p_switch_cache_db_handle.getCPtr(dbh), sql, str, len, ref err); return ret; } - public static switch_status_t switch_cache_db_execute_sql_callback(switch_cache_db_handle_t dbh, string sql, SWIGTYPE_p_f_p_void_int_p_p_char_p_p_char__int callback, SWIGTYPE_p_void pdata, ref string err) { - switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_cache_db_execute_sql_callback(switch_cache_db_handle_t.getCPtr(dbh), sql, SWIGTYPE_p_f_p_void_int_p_p_char_p_p_char__int.getCPtr(callback), SWIGTYPE_p_void.getCPtr(pdata), ref err); + public static switch_status_t switch_cache_db_execute_sql(SWIGTYPE_p_switch_cache_db_handle dbh, string sql, ref string err) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_cache_db_execute_sql(SWIGTYPE_p_switch_cache_db_handle.getCPtr(dbh), sql, ref err); return ret; } - public static int switch_cache_db_affected_rows(switch_cache_db_handle_t dbh) { - int ret = freeswitchPINVOKE.switch_cache_db_affected_rows(switch_cache_db_handle_t.getCPtr(dbh)); + public static switch_status_t switch_cache_db_execute_sql_callback(SWIGTYPE_p_switch_cache_db_handle dbh, string sql, SWIGTYPE_p_f_p_void_int_p_p_char_p_p_char__int callback, SWIGTYPE_p_void pdata, ref string err) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_cache_db_execute_sql_callback(SWIGTYPE_p_switch_cache_db_handle.getCPtr(dbh), sql, SWIGTYPE_p_f_p_void_int_p_p_char_p_p_char__int.getCPtr(callback), SWIGTYPE_p_void.getCPtr(pdata), ref err); + return ret; + } + + public static int switch_cache_db_affected_rows(SWIGTYPE_p_switch_cache_db_handle dbh) { + int ret = freeswitchPINVOKE.switch_cache_db_affected_rows(SWIGTYPE_p_switch_cache_db_handle.getCPtr(dbh)); return ret; } @@ -2367,30 +2383,26 @@ public class freeswitch { freeswitchPINVOKE.switch_cache_db_status(switch_stream_handle.getCPtr(stream)); } - public static switch_status_t _switch_core_db_handle(SWIGTYPE_p_p_switch_cache_db_handle_t dbh, string file, string func, int line) { - switch_status_t ret = (switch_status_t)freeswitchPINVOKE._switch_core_db_handle(SWIGTYPE_p_p_switch_cache_db_handle_t.getCPtr(dbh), file, func, line); + public static switch_status_t _switch_core_db_handle(SWIGTYPE_p_p_switch_cache_db_handle dbh, string file, string func, int line) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE._switch_core_db_handle(SWIGTYPE_p_p_switch_cache_db_handle.getCPtr(dbh), file, func, line); return ret; } - public static switch_bool_t switch_cache_db_test_reactive(switch_cache_db_handle_t db, string test_sql, string drop_sql, string reactive_sql) { - switch_bool_t ret = (switch_bool_t)freeswitchPINVOKE.switch_cache_db_test_reactive(switch_cache_db_handle_t.getCPtr(db), test_sql, drop_sql, reactive_sql); + public static switch_bool_t switch_cache_db_test_reactive(SWIGTYPE_p_switch_cache_db_handle db, string test_sql, string drop_sql, string reactive_sql) { + switch_bool_t ret = (switch_bool_t)freeswitchPINVOKE.switch_cache_db_test_reactive(SWIGTYPE_p_switch_cache_db_handle.getCPtr(db), test_sql, drop_sql, reactive_sql); return ret; } - public static switch_status_t switch_cache_db_persistant_execute(switch_cache_db_handle_t dbh, string sql, uint retries) { - switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_cache_db_persistant_execute(switch_cache_db_handle_t.getCPtr(dbh), sql, retries); + public static switch_status_t switch_cache_db_persistant_execute(SWIGTYPE_p_switch_cache_db_handle dbh, string sql, uint retries) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_cache_db_persistant_execute(SWIGTYPE_p_switch_cache_db_handle.getCPtr(dbh), sql, retries); return ret; } - public static switch_status_t switch_cache_db_persistant_execute_trans(switch_cache_db_handle_t dbh, string sql, uint retries) { - switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_cache_db_persistant_execute_trans(switch_cache_db_handle_t.getCPtr(dbh), sql, retries); + public static switch_status_t switch_cache_db_persistant_execute_trans(SWIGTYPE_p_switch_cache_db_handle dbh, string sql, uint retries) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_cache_db_persistant_execute_trans(SWIGTYPE_p_switch_cache_db_handle.getCPtr(dbh), sql, retries); return ret; } - public static void switch_cache_db_detach() { - freeswitchPINVOKE.switch_cache_db_detach(); - } - public static uint switch_core_debug_level() { uint ret = freeswitchPINVOKE.switch_core_debug_level(); return ret; @@ -2415,6 +2427,21 @@ public class freeswitch { return ret; } + public static switch_status_t switch_core_add_registration(string user, string realm, string token, string url, uint expires, string network_ip, string network_port, string network_proto) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_add_registration(user, realm, token, url, expires, network_ip, network_port, network_proto); + return ret; + } + + public static switch_status_t switch_core_del_registration(string user, string realm, string token) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_del_registration(user, realm, token); + return ret; + } + + public static switch_status_t switch_core_expire_registration(int force) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_expire_registration(force); + return ret; + } + public static switch_status_t switch_loadable_module_init(switch_bool_t autoload) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_loadable_module_init((int)autoload); return ret; @@ -3974,6 +4001,10 @@ public class freeswitch { freeswitchPINVOKE.switch_change_sln_volume(SWIGTYPE_p_short.getCPtr(data), samples, vol); } + public static void switch_change_sln_volume_granular(SWIGTYPE_p_short data, uint samples, int vol) { + freeswitchPINVOKE.switch_change_sln_volume_granular(SWIGTYPE_p_short.getCPtr(data), samples, vol); + } + public static uint switch_merge_sln(SWIGTYPE_p_short data, uint samples, SWIGTYPE_p_short other_data, uint other_samples) { uint ret = freeswitchPINVOKE.switch_merge_sln(SWIGTYPE_p_short.getCPtr(data), samples, SWIGTYPE_p_short.getCPtr(other_data), other_samples); return ret; @@ -4719,8 +4750,8 @@ public class freeswitch { return ret; } - public static switch_status_t switch_rtp_activate_jitter_buffer(SWIGTYPE_p_switch_rtp rtp_session, uint queue_frames, uint max_queue_frames, uint samples_per_packet, uint samples_per_second) { - switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_rtp_activate_jitter_buffer(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), queue_frames, max_queue_frames, samples_per_packet, samples_per_second); + public static switch_status_t switch_rtp_activate_jitter_buffer(SWIGTYPE_p_switch_rtp rtp_session, uint queue_frames, uint max_queue_frames, uint samples_per_packet, uint samples_per_second, uint max_drift) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_rtp_activate_jitter_buffer(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), queue_frames, max_queue_frames, samples_per_packet, samples_per_second, max_drift); return ret; } @@ -4857,6 +4888,10 @@ public class freeswitch { freeswitchPINVOKE.switch_rtp_set_telephony_recv_event(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), te); } + public static void switch_rtp_set_recv_pt(SWIGTYPE_p_switch_rtp rtp_session, byte pt) { + freeswitchPINVOKE.switch_rtp_set_recv_pt(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), pt); + } + public static void switch_rtp_set_cng_pt(SWIGTYPE_p_switch_rtp rtp_session, byte pt) { freeswitchPINVOKE.switch_rtp_set_cng_pt(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), pt); } @@ -7569,6 +7604,15 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_get_variable")] public static extern string switch_core_get_variable(string jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_get_variable_dup")] + public static extern string switch_core_get_variable_dup(string jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_get_variable_pdup")] + public static extern string switch_core_get_variable_pdup(string jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_get_hostname")] + public static extern string switch_core_get_hostname(); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_set_variable")] public static extern void switch_core_set_variable(string jarg1, string jarg2); @@ -8217,90 +8261,18 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_delete_switch_cache_db_connection_options_t")] public static extern void delete_switch_cache_db_connection_options_t(HandleRef jarg1); - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_name_set")] - public static extern void switch_cache_db_handle_t_name_set(HandleRef jarg1, string jarg2); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_name_get")] - public static extern string switch_cache_db_handle_t_name_get(HandleRef jarg1); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_type_set")] - public static extern void switch_cache_db_handle_t_type_set(HandleRef jarg1, int jarg2); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_type_get")] - public static extern int switch_cache_db_handle_t_type_get(HandleRef jarg1); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_native_handle_set")] - public static extern void switch_cache_db_handle_t_native_handle_set(HandleRef jarg1, HandleRef jarg2); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_native_handle_get")] - public static extern IntPtr switch_cache_db_handle_t_native_handle_get(HandleRef jarg1); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_last_used_set")] - public static extern void switch_cache_db_handle_t_last_used_set(HandleRef jarg1, HandleRef jarg2); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_last_used_get")] - public static extern IntPtr switch_cache_db_handle_t_last_used_get(HandleRef jarg1); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_mutex_set")] - public static extern void switch_cache_db_handle_t_mutex_set(HandleRef jarg1, HandleRef jarg2); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_mutex_get")] - public static extern IntPtr switch_cache_db_handle_t_mutex_get(HandleRef jarg1); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_io_mutex_set")] - public static extern void switch_cache_db_handle_t_io_mutex_set(HandleRef jarg1, HandleRef jarg2); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_io_mutex_get")] - public static extern IntPtr switch_cache_db_handle_t_io_mutex_get(HandleRef jarg1); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_pool_set")] - public static extern void switch_cache_db_handle_t_pool_set(HandleRef jarg1, HandleRef jarg2); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_pool_get")] - public static extern IntPtr switch_cache_db_handle_t_pool_get(HandleRef jarg1); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_flags_set")] - public static extern void switch_cache_db_handle_t_flags_set(HandleRef jarg1, int jarg2); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_flags_get")] - public static extern int switch_cache_db_handle_t_flags_get(HandleRef jarg1); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_hash_set")] - public static extern void switch_cache_db_handle_t_hash_set(HandleRef jarg1, uint jarg2); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_hash_get")] - public static extern uint switch_cache_db_handle_t_hash_get(HandleRef jarg1); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_creator_set")] - public static extern void switch_cache_db_handle_t_creator_set(HandleRef jarg1, string jarg2); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_creator_get")] - public static extern string switch_cache_db_handle_t_creator_get(HandleRef jarg1); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_last_user_set")] - public static extern void switch_cache_db_handle_t_last_user_set(HandleRef jarg1, string jarg2); - - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_handle_t_last_user_get")] - public static extern string switch_cache_db_handle_t_last_user_get(HandleRef jarg1); - - [DllImport("mod_managed", EntryPoint="CSharp_new_switch_cache_db_handle_t")] - public static extern IntPtr new_switch_cache_db_handle_t(); - - [DllImport("mod_managed", EntryPoint="CSharp_delete_switch_cache_db_handle_t")] - public static extern void delete_switch_cache_db_handle_t(HandleRef jarg1); - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_type_name")] public static extern string switch_cache_db_type_name(int jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_get_type")] + public static extern int switch_cache_db_get_type(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_dismiss_db_handle")] public static extern void switch_cache_db_dismiss_db_handle(HandleRef jarg1); [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_release_db_handle")] public static extern void switch_cache_db_release_db_handle(HandleRef jarg1); - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_destroy_db_handle")] - public static extern void switch_cache_db_destroy_db_handle(HandleRef jarg1); - [DllImport("mod_managed", EntryPoint="CSharp__switch_cache_db_get_db_handle")] public static extern int _switch_cache_db_get_db_handle(HandleRef jarg1, int jarg2, HandleRef jarg3, string jarg4, string jarg5, int jarg6); @@ -8331,9 +8303,6 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_persistant_execute_trans")] public static extern int switch_cache_db_persistant_execute_trans(HandleRef jarg1, string jarg2, uint jarg3); - [DllImport("mod_managed", EntryPoint="CSharp_switch_cache_db_detach")] - public static extern void switch_cache_db_detach(); - [DllImport("mod_managed", EntryPoint="CSharp_switch_core_debug_level")] public static extern uint switch_core_debug_level(); @@ -8349,6 +8318,15 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_default_ptime")] public static extern uint switch_default_ptime(string jarg1, uint jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_add_registration")] + public static extern int switch_core_add_registration(string jarg1, string jarg2, string jarg3, string jarg4, uint jarg5, string jarg6, string jarg7, string jarg8); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_del_registration")] + public static extern int switch_core_del_registration(string jarg1, string jarg2, string jarg3); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_expire_registration")] + public static extern int switch_core_expire_registration(int jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_loadable_module_interface_module_name_set")] public static extern void switch_loadable_module_interface_module_name_set(HandleRef jarg1, string jarg2); @@ -12042,6 +12020,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_change_sln_volume")] public static extern void switch_change_sln_volume(HandleRef jarg1, uint jarg2, int jarg3); + [DllImport("mod_managed", EntryPoint="CSharp_switch_change_sln_volume_granular")] + public static extern void switch_change_sln_volume_granular(HandleRef jarg1, uint jarg2, int jarg3); + [DllImport("mod_managed", EntryPoint="CSharp_switch_merge_sln")] public static extern uint switch_merge_sln(HandleRef jarg1, uint jarg2, HandleRef jarg3, uint jarg4); @@ -12652,7 +12633,7 @@ class freeswitchPINVOKE { public static extern int switch_rtp_activate_rtcp(HandleRef jarg1, int jarg2, ushort jarg3); [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_activate_jitter_buffer")] - public static extern int switch_rtp_activate_jitter_buffer(HandleRef jarg1, uint jarg2, uint jarg3, uint jarg4, uint jarg5); + public static extern int switch_rtp_activate_jitter_buffer(HandleRef jarg1, uint jarg2, uint jarg3, uint jarg4, uint jarg5, uint jarg6); [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_debug_jitter_buffer")] public static extern int switch_rtp_debug_jitter_buffer(HandleRef jarg1, string jarg2); @@ -12738,6 +12719,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_set_telephony_recv_event")] public static extern void switch_rtp_set_telephony_recv_event(HandleRef jarg1, byte jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_set_recv_pt")] + public static extern void switch_rtp_set_recv_pt(HandleRef jarg1, byte jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_rtp_set_cng_pt")] public static extern void switch_rtp_set_cng_pt(HandleRef jarg1, byte jarg2); @@ -17139,18 +17123,18 @@ namespace FreeSWITCH.Native { using System; using System.Runtime.InteropServices; -public class SWIGTYPE_p_p_switch_cache_db_handle_t { +public class SWIGTYPE_p_p_switch_cache_db_handle { private HandleRef swigCPtr; - internal SWIGTYPE_p_p_switch_cache_db_handle_t(IntPtr cPtr, bool futureUse) { + internal SWIGTYPE_p_p_switch_cache_db_handle(IntPtr cPtr, bool futureUse) { swigCPtr = new HandleRef(this, cPtr); } - protected SWIGTYPE_p_p_switch_cache_db_handle_t() { + protected SWIGTYPE_p_p_switch_cache_db_handle() { swigCPtr = new HandleRef(null, IntPtr.Zero); } - internal static HandleRef getCPtr(SWIGTYPE_p_p_switch_cache_db_handle_t obj) { + internal static HandleRef getCPtr(SWIGTYPE_p_p_switch_cache_db_handle obj) { return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; } } @@ -18159,6 +18143,36 @@ namespace FreeSWITCH.Native { using System; using System.Runtime.InteropServices; +public class SWIGTYPE_p_switch_cache_db_handle { + private HandleRef swigCPtr; + + internal SWIGTYPE_p_switch_cache_db_handle(IntPtr cPtr, bool futureUse) { + swigCPtr = new HandleRef(this, cPtr); + } + + protected SWIGTYPE_p_switch_cache_db_handle() { + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + + internal static HandleRef getCPtr(SWIGTYPE_p_switch_cache_db_handle obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } +} + +} +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.35 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace FreeSWITCH.Native { + +using System; +using System.Runtime.InteropServices; + public class SWIGTYPE_p_switch_call_cause_t { private HandleRef swigCPtr; @@ -20653,169 +20667,6 @@ public class switch_cache_db_core_db_options_t : IDisposable { namespace FreeSWITCH.Native { -using System; -using System.Runtime.InteropServices; - -public class switch_cache_db_handle_t : IDisposable { - private HandleRef swigCPtr; - protected bool swigCMemOwn; - - internal switch_cache_db_handle_t(IntPtr cPtr, bool cMemoryOwn) { - swigCMemOwn = cMemoryOwn; - swigCPtr = new HandleRef(this, cPtr); - } - - internal static HandleRef getCPtr(switch_cache_db_handle_t obj) { - return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; - } - - ~switch_cache_db_handle_t() { - Dispose(); - } - - public virtual void Dispose() { - lock(this) { - if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { - swigCMemOwn = false; - freeswitchPINVOKE.delete_switch_cache_db_handle_t(swigCPtr); - } - swigCPtr = new HandleRef(null, IntPtr.Zero); - GC.SuppressFinalize(this); - } - } - - public string name { - set { - freeswitchPINVOKE.switch_cache_db_handle_t_name_set(swigCPtr, value); - } - get { - string ret = freeswitchPINVOKE.switch_cache_db_handle_t_name_get(swigCPtr); - return ret; - } - } - - public switch_cache_db_handle_type_t type { - set { - freeswitchPINVOKE.switch_cache_db_handle_t_type_set(swigCPtr, (int)value); - } - get { - switch_cache_db_handle_type_t ret = (switch_cache_db_handle_type_t)freeswitchPINVOKE.switch_cache_db_handle_t_type_get(swigCPtr); - return ret; - } - } - - public switch_cache_db_native_handle_t native_handle { - set { - freeswitchPINVOKE.switch_cache_db_handle_t_native_handle_set(swigCPtr, switch_cache_db_native_handle_t.getCPtr(value)); - } - get { - IntPtr cPtr = freeswitchPINVOKE.switch_cache_db_handle_t_native_handle_get(swigCPtr); - switch_cache_db_native_handle_t ret = (cPtr == IntPtr.Zero) ? null : new switch_cache_db_native_handle_t(cPtr, false); - return ret; - } - } - - public SWIGTYPE_p_time_t last_used { - set { - freeswitchPINVOKE.switch_cache_db_handle_t_last_used_set(swigCPtr, SWIGTYPE_p_time_t.getCPtr(value)); - if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); - } - get { - SWIGTYPE_p_time_t ret = new SWIGTYPE_p_time_t(freeswitchPINVOKE.switch_cache_db_handle_t_last_used_get(swigCPtr), true); - if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); - return ret; - } - } - - public SWIGTYPE_p_switch_mutex_t mutex { - set { - freeswitchPINVOKE.switch_cache_db_handle_t_mutex_set(swigCPtr, SWIGTYPE_p_switch_mutex_t.getCPtr(value)); - } - get { - IntPtr cPtr = freeswitchPINVOKE.switch_cache_db_handle_t_mutex_get(swigCPtr); - SWIGTYPE_p_switch_mutex_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_switch_mutex_t(cPtr, false); - return ret; - } - } - - public SWIGTYPE_p_switch_mutex_t io_mutex { - set { - freeswitchPINVOKE.switch_cache_db_handle_t_io_mutex_set(swigCPtr, SWIGTYPE_p_switch_mutex_t.getCPtr(value)); - } - get { - IntPtr cPtr = freeswitchPINVOKE.switch_cache_db_handle_t_io_mutex_get(swigCPtr); - SWIGTYPE_p_switch_mutex_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_switch_mutex_t(cPtr, false); - return ret; - } - } - - public SWIGTYPE_p_apr_pool_t pool { - set { - freeswitchPINVOKE.switch_cache_db_handle_t_pool_set(swigCPtr, SWIGTYPE_p_apr_pool_t.getCPtr(value)); - } - get { - IntPtr cPtr = freeswitchPINVOKE.switch_cache_db_handle_t_pool_get(swigCPtr); - SWIGTYPE_p_apr_pool_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_apr_pool_t(cPtr, false); - return ret; - } - } - - public int flags { - set { - freeswitchPINVOKE.switch_cache_db_handle_t_flags_set(swigCPtr, value); - } - get { - int ret = freeswitchPINVOKE.switch_cache_db_handle_t_flags_get(swigCPtr); - return ret; - } - } - - public uint hash { - set { - freeswitchPINVOKE.switch_cache_db_handle_t_hash_set(swigCPtr, value); - } - get { - uint ret = freeswitchPINVOKE.switch_cache_db_handle_t_hash_get(swigCPtr); - return ret; - } - } - - public string creator { - set { - freeswitchPINVOKE.switch_cache_db_handle_t_creator_set(swigCPtr, value); - } - get { - string ret = freeswitchPINVOKE.switch_cache_db_handle_t_creator_get(swigCPtr); - return ret; - } - } - - public string last_user { - set { - freeswitchPINVOKE.switch_cache_db_handle_t_last_user_set(swigCPtr, value); - } - get { - string ret = freeswitchPINVOKE.switch_cache_db_handle_t_last_user_get(swigCPtr); - return ret; - } - } - - public switch_cache_db_handle_t() : this(freeswitchPINVOKE.new_switch_cache_db_handle_t(), true) { - } - -} - -} -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 - * - * Do not make changes to this file unless you know what you are doing--modify - * the SWIG interface file instead. - * ----------------------------------------------------------------------------- */ - -namespace FreeSWITCH.Native { - public enum switch_cache_db_handle_type_t { SCDB_TYPE_CORE_DB, SCDB_TYPE_ODBC @@ -24889,6 +24740,8 @@ public enum switch_event_types_t { SWITCH_EVENT_NAT, SWITCH_EVENT_RECORD_START, SWITCH_EVENT_RECORD_STOP, + SWITCH_EVENT_PLAYBACK_START, + SWITCH_EVENT_PLAYBACK_STOP, SWITCH_EVENT_CALL_UPDATE, SWITCH_EVENT_FAILURE, SWITCH_EVENT_SOCKET_DATA, diff --git a/src/mod/languages/mod_perl/freeswitch.pm b/src/mod/languages/mod_perl/freeswitch.pm index cb31101489..e55ffac7de 100644 --- a/src/mod/languages/mod_perl/freeswitch.pm +++ b/src/mod/languages/mod_perl/freeswitch.pm @@ -50,6 +50,7 @@ package freeswitch; *consoleLog = *freeswitchc::consoleLog; *consoleCleanLog = *freeswitchc::consoleCleanLog; +*email = *freeswitchc::email; *console_log = *freeswitchc::console_log; *console_clean_log = *freeswitchc::console_clean_log; *msleep = *freeswitchc::msleep; diff --git a/src/mod/languages/mod_perl/mod_perl_wrap.cpp b/src/mod/languages/mod_perl/mod_perl_wrap.cpp index e8a4b9f409..079bec0866 100644 --- a/src/mod/languages/mod_perl/mod_perl_wrap.cpp +++ b/src/mod/languages/mod_perl/mod_perl_wrap.cpp @@ -1566,6 +1566,19 @@ SWIG_AsCharPtrAndSize(SV *obj, char** cptr, size_t* psize, int *alloc) +SWIGINTERNINLINE SV * +SWIG_From_bool SWIG_PERL_DECL_ARGS_1(bool value) +{ + SV *obj = sv_newmortal(); + if (value) { + sv_setsv(obj, &PL_sv_yes); + } else { + sv_setsv(obj, &PL_sv_no); + } + return obj; +} + + #include #if !defined(SWIG_NO_LLONG_MAX) # if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__) @@ -1780,19 +1793,6 @@ SWIG_From_char SWIG_PERL_DECL_ARGS_1(char c) } -SWIGINTERNINLINE SV * -SWIG_From_bool SWIG_PERL_DECL_ARGS_1(bool value) -{ - SV *obj = sv_newmortal(); - if (value) { - sv_setsv(obj, &PL_sv_yes); - } else { - sv_setsv(obj, &PL_sv_no); - } - return obj; -} - - SWIGINTERN int SWIG_AsVal_unsigned_SS_long SWIG_PERL_DECL_ARGS_2(SV *obj, unsigned long *val) { @@ -1982,6 +1982,111 @@ XS(_wrap_consoleCleanLog) { } +XS(_wrap_email) { + { + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) NULL ; + char *arg4 = (char *) NULL ; + char *arg5 = (char *) NULL ; + char *arg6 = (char *) NULL ; + char *arg7 = (char *) NULL ; + bool result; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + int res5 ; + char *buf5 = 0 ; + int alloc5 = 0 ; + int res6 ; + char *buf6 = 0 ; + int alloc6 = 0 ; + int res7 ; + char *buf7 = 0 ; + int alloc7 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 2) || (items > 7)) { + SWIG_croak("Usage: email(to,from,headers,body,file,convert_cmd,convert_ext);"); + } + res1 = SWIG_AsCharPtrAndSize(ST(0), &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "email" "', argument " "1"" of type '" "char *""'"); + } + arg1 = reinterpret_cast< char * >(buf1); + res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "email" "', argument " "2"" of type '" "char *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + if (items > 2) { + res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "email" "', argument " "3"" of type '" "char *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + } + if (items > 3) { + res4 = SWIG_AsCharPtrAndSize(ST(3), &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "email" "', argument " "4"" of type '" "char *""'"); + } + arg4 = reinterpret_cast< char * >(buf4); + } + if (items > 4) { + res5 = SWIG_AsCharPtrAndSize(ST(4), &buf5, NULL, &alloc5); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "email" "', argument " "5"" of type '" "char *""'"); + } + arg5 = reinterpret_cast< char * >(buf5); + } + if (items > 5) { + res6 = SWIG_AsCharPtrAndSize(ST(5), &buf6, NULL, &alloc6); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "email" "', argument " "6"" of type '" "char *""'"); + } + arg6 = reinterpret_cast< char * >(buf6); + } + if (items > 6) { + res7 = SWIG_AsCharPtrAndSize(ST(6), &buf7, NULL, &alloc7); + if (!SWIG_IsOK(res7)) { + SWIG_exception_fail(SWIG_ArgError(res7), "in method '" "email" "', argument " "7"" of type '" "char *""'"); + } + arg7 = reinterpret_cast< char * >(buf7); + } + result = (bool)email(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + ST(argvi) = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >(result)); argvi++ ; + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + if (alloc5 == SWIG_NEWOBJ) delete[] buf5; + if (alloc6 == SWIG_NEWOBJ) delete[] buf6; + if (alloc7 == SWIG_NEWOBJ) delete[] buf7; + XSRETURN(argvi); + fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + if (alloc5 == SWIG_NEWOBJ) delete[] buf5; + if (alloc6 == SWIG_NEWOBJ) delete[] buf6; + if (alloc7 == SWIG_NEWOBJ) delete[] buf7; + SWIG_croak_null(); + } +} + + XS(_wrap_new_IVRMenu) { { IVRMenu *arg1 = (IVRMenu *) 0 ; @@ -9336,6 +9441,7 @@ static swig_variable_info swig_variables[] = { static swig_command_info swig_commands[] = { {"freeswitchc::consoleLog", _wrap_consoleLog}, {"freeswitchc::consoleCleanLog", _wrap_consoleCleanLog}, +{"freeswitchc::email", _wrap_email}, {"freeswitchc::new_IVRMenu", _wrap_new_IVRMenu}, {"freeswitchc::delete_IVRMenu", _wrap_delete_IVRMenu}, {"freeswitchc::IVRMenu_bindAction", _wrap_IVRMenu_bindAction}, diff --git a/src/mod/languages/mod_python/freeswitch.py b/src/mod/languages/mod_python/freeswitch.py index 03deb31d13..d49016d305 100644 --- a/src/mod/languages/mod_python/freeswitch.py +++ b/src/mod/languages/mod_python/freeswitch.py @@ -50,6 +50,7 @@ del types consoleLog = _freeswitch.consoleLog consoleCleanLog = _freeswitch.consoleCleanLog +email = _freeswitch.email class IVRMenu(_object): __swig_setmethods__ = {} __setattr__ = lambda self, name, value: _swig_setattr(self, IVRMenu, name, value) diff --git a/src/mod/languages/mod_python/mod_python_wrap.cpp b/src/mod/languages/mod_python/mod_python_wrap.cpp index 3326a19dcd..ccb5cac78e 100644 --- a/src/mod/languages/mod_python/mod_python_wrap.cpp +++ b/src/mod/languages/mod_python/mod_python_wrap.cpp @@ -2687,6 +2687,13 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) +SWIGINTERNINLINE PyObject* + SWIG_From_bool (bool value) +{ + return PyBool_FromLong(value ? 1 : 0); +} + + #include #if !defined(SWIG_NO_LLONG_MAX) # if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__) @@ -2916,13 +2923,6 @@ SWIG_From_char (char c) } -SWIGINTERNINLINE PyObject* - SWIG_From_bool (bool value) -{ - return PyBool_FromLong(value ? 1 : 0); -} - - SWIGINTERN int SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val) { @@ -3071,6 +3071,113 @@ fail: } +SWIGINTERN PyObject *_wrap_email(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) NULL ; + char *arg4 = (char *) NULL ; + char *arg5 = (char *) NULL ; + char *arg6 = (char *) NULL ; + char *arg7 = (char *) NULL ; + bool result; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + int res5 ; + char *buf5 = 0 ; + int alloc5 = 0 ; + int res6 ; + char *buf6 = 0 ; + int alloc6 = 0 ; + int res7 ; + char *buf7 = 0 ; + int alloc7 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO|OOOOO:email",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "email" "', argument " "1"" of type '" "char *""'"); + } + arg1 = reinterpret_cast< char * >(buf1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "email" "', argument " "2"" of type '" "char *""'"); + } + arg2 = reinterpret_cast< char * >(buf2); + if (obj2) { + res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "email" "', argument " "3"" of type '" "char *""'"); + } + arg3 = reinterpret_cast< char * >(buf3); + } + if (obj3) { + res4 = SWIG_AsCharPtrAndSize(obj3, &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "email" "', argument " "4"" of type '" "char *""'"); + } + arg4 = reinterpret_cast< char * >(buf4); + } + if (obj4) { + res5 = SWIG_AsCharPtrAndSize(obj4, &buf5, NULL, &alloc5); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "email" "', argument " "5"" of type '" "char *""'"); + } + arg5 = reinterpret_cast< char * >(buf5); + } + if (obj5) { + res6 = SWIG_AsCharPtrAndSize(obj5, &buf6, NULL, &alloc6); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "email" "', argument " "6"" of type '" "char *""'"); + } + arg6 = reinterpret_cast< char * >(buf6); + } + if (obj6) { + res7 = SWIG_AsCharPtrAndSize(obj6, &buf7, NULL, &alloc7); + if (!SWIG_IsOK(res7)) { + SWIG_exception_fail(SWIG_ArgError(res7), "in method '" "email" "', argument " "7"" of type '" "char *""'"); + } + arg7 = reinterpret_cast< char * >(buf7); + } + result = (bool)email(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + if (alloc5 == SWIG_NEWOBJ) delete[] buf5; + if (alloc6 == SWIG_NEWOBJ) delete[] buf6; + if (alloc7 == SWIG_NEWOBJ) delete[] buf7; + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + if (alloc2 == SWIG_NEWOBJ) delete[] buf2; + if (alloc3 == SWIG_NEWOBJ) delete[] buf3; + if (alloc4 == SWIG_NEWOBJ) delete[] buf4; + if (alloc5 == SWIG_NEWOBJ) delete[] buf5; + if (alloc6 == SWIG_NEWOBJ) delete[] buf6; + if (alloc7 == SWIG_NEWOBJ) delete[] buf7; + return NULL; +} + + SWIGINTERN PyObject *_wrap_new_IVRMenu(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; IVRMenu *arg1 = (IVRMenu *) 0 ; @@ -8878,6 +8985,7 @@ SWIGINTERN PyObject *Session_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObje static PyMethodDef SwigMethods[] = { { (char *)"consoleLog", _wrap_consoleLog, METH_VARARGS, NULL}, { (char *)"consoleCleanLog", _wrap_consoleCleanLog, METH_VARARGS, NULL}, + { (char *)"email", _wrap_email, METH_VARARGS, NULL}, { (char *)"new_IVRMenu", _wrap_new_IVRMenu, METH_VARARGS, NULL}, { (char *)"delete_IVRMenu", _wrap_delete_IVRMenu, METH_VARARGS, NULL}, { (char *)"IVRMenu_bindAction", _wrap_IVRMenu_bindAction, METH_VARARGS, NULL}, diff --git a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c index a818c1dcd1..1a57f5f2ae 100644 --- a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c +++ b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c @@ -2882,8 +2882,8 @@ static JSBool session_construct(JSContext * cx, JSObject * obj, uintN argc, jsva if (switch_ivr_originate(old_jss ? old_jss->session : NULL, &jss->session, &jss->cause, uuid, 60, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL) == SWITCH_STATUS_SUCCESS) { switch_set_flag(jss, S_HUP); - switch_channel_set_state(switch_core_session_get_channel(jss->session), CS_SOFT_EXECUTE); - switch_channel_wait_for_state_timeout(switch_core_session_get_channel(jss->session), CS_SOFT_EXECUTE, 5000); + //switch_channel_set_state(switch_core_session_get_channel(jss->session), CS_SOFT_EXECUTE); + //switch_channel_wait_for_state_timeout(switch_core_session_get_channel(jss->session), CS_SOFT_EXECUTE, 5000); *rval = BOOLEAN_TO_JSVAL(JS_TRUE); } else { *rval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, switch_channel_cause2str(jss->cause))); @@ -3054,7 +3054,7 @@ static JSBool session_originate(JSContext * cx, JSObject * obj, uintN argc, jsva jss->session = peer_session; switch_set_flag(jss, S_HUP); *rval = BOOLEAN_TO_JSVAL(JS_TRUE); - switch_channel_set_state(switch_core_session_get_channel(jss->session), CS_SOFT_EXECUTE); + //switch_channel_set_state(switch_core_session_get_channel(jss->session), CS_SOFT_EXECUTE); } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Missing Args\n"); diff --git a/src/mod/sdk/autotools/.gitignore b/src/mod/sdk/autotools/.gitignore new file mode 100644 index 0000000000..57b51acef5 --- /dev/null +++ b/src/mod/sdk/autotools/.gitignore @@ -0,0 +1,35 @@ +*.o +*.lo +*.so +*.a +*.orig +*.rej +*.log +*.la + +.deps +.libs + +stamp-h1 +samples* +Makefile +Makefile.in +config.log +config.sub +config.guess +config.status +configure +libtool +aclocal.m4 +autom4te.cache +depcomp +install-sh +compile +missing +ltmain.sh +doxygen +m4/libtool.m4 +m4/ltsugar.m4 +m4/ltoptions.m4 +m4/ltversion.m4 +m4/lt~obsolete.m4 diff --git a/src/mod/sdk/autotools/Makefile.am b/src/mod/sdk/autotools/Makefile.am new file mode 100644 index 0000000000..8f8a25a048 --- /dev/null +++ b/src/mod/sdk/autotools/Makefile.am @@ -0,0 +1,4 @@ +ACLOCAL_AMFLAGS = -I m4 +AUTOMAKE_OPTIONS = foreign no-dist subdir-objects + +SUBDIRS = src diff --git a/src/mod/sdk/autotools/autogen.sh b/src/mod/sdk/autotools/autogen.sh new file mode 100755 index 0000000000..08240fdfcd --- /dev/null +++ b/src/mod/sdk/autotools/autogen.sh @@ -0,0 +1,2 @@ +#!/bin/sh +autoreconf -i -f diff --git a/src/mod/sdk/autotools/configure.ac b/src/mod/sdk/autotools/configure.ac new file mode 100644 index 0000000000..d4f29f492b --- /dev/null +++ b/src/mod/sdk/autotools/configure.ac @@ -0,0 +1,252 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +# website url +m4_define([AC_PACKAGE_URL], [http://www.example.com/]) + +AC_PREREQ([2.61]) +AC_INIT([mod_example], [0.0.0], [contact@example.com]) +AC_CONFIG_SRCDIR([src/mod_example.c]) +AC_CONFIG_MACRO_DIR([m4]) + +AM_INIT_AUTOMAKE([foreign no-dist subdir-objects]) +AC_DISABLE_STATIC + +# disable libtool fortran and c++ checks +m4_defun([_LT_AC_LANG_F77_CONFIG], [:]) +m4_defun([_LT_AC_LANG_CXX_CONFIG], [:]) + +# >=automake-1.11 +m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) + +# Checks for programs. +AC_PROG_CC +AM_PROG_CC_C_O +AC_PROG_LIBTOOL + +# pkgconfig +AC_PATH_PROG([PKG_CONFIG], [pkg-config], ["no"]) +if test "x${PKG_CONFIG}" = "xno" +then + AC_MSG_ERROR([Cannot find pkg-config, make sure it is installed in your PATH]) +fi +PKG_PROG_PKG_CONFIG + +# Checks for cflags +AC_MSG_RESULT([${as_nl}<<>> Compiler vendor and features]) + +## +## Compiler vendor and flag checks +## +HAVE_VISIBILITY="no" +AC_ARG_ENABLE([visibility], + [AS_HELP_STRING([--disable-visibility], [Disable symbol visibility support (default: enabled, if available)])], + [case "${enableval}" in + yes) enable_visibility="yes" ;; + no) enable_visibility="no" ;; + *) AC_MSG_ERROR([Invalid value ${enableval} for parameter --disable-visibility]) ;; + esac], + [enable_visibility="yes"] +) + +AX_COMPILER_VENDOR + +case "${ax_cv_c_compiler_vendor}" in +gnu) + AC_MSG_CHECKING([whether the compiler supports -fvisibility=hidden]) + AS_IF([test "x${enable_visibility}" != "xno"], + [save_CFLAGS="${CFLAGS}" + CFLAGS="${CFLAGS} -fvisibility=hidden" + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [int foo __attribute__ ((visibility("default")));], + [;] + )], + + [AC_MSG_RESULT([yes]) + AC_DEFINE([HAVE_VISIBILITY],[1],[GCC visibility support]) + HAVE_VISIBILITY="yes"], + + [AC_MSG_RESULT([no]) + HAVE_VISIBILITY="no"] + ) + CFLAGS="${save_CFLAGS}"], + [AC_MSG_RESULT([disabled by user])] + ) + + AS_IF([test "x${HAVE_VISIBILITY}" != "xno"], + [save_CFLAGS="${CFLAGS}" + CFLAGS="${CFLAGS} -fvisibility-inlines-hidden" + AC_MSG_CHECKING([whether the compiler supports -fvisibility-inlines-hidden]) + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [;], [;] + )], + + [AC_MSG_RESULT([yes]) + HAVE_VISIBILITY_INLINES_HIDDEN="yes"], + + [AC_MSG_RESULT([no]) + HAVE_VISIBILITY_INLINES_HIDDEN="no"] + ) + CFLAGS="${save_CFLAGS}"], + [:] + ) + AC_DEFINE([COMPILER_GCC], [1], [Compiler is GCC]) + ;; +sun) + AC_MSG_CHECKING([whether the compiler supports -xldscope=hidden]) + AS_IF([test "x${enable_visibility}" != "xno"], + [save_CFLAGS="${CFLAGS}" + CFLAGS="${CFLAGS} -xldscope=hidden" + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [int foo __attribute__ ((visibility("default")));], + [;] + )], + + [AC_MSG_RESULT([yes]) + AC_DEFINE([HAVE_VISIBILITY],[1],[SUNCC visibility support]) + HAVE_VISIBILITY="yes"], + + [AC_MSG_RESULT([no]) + HAVE_VISIBILITY="no"] + ) + CFLAGS="${save_CFLAGS}"], + [AC_MSG_RESULT([disabled by user])] + ) + AC_DEFINE([COMPILER_SUNCC], [1], [Compiler is SunCC]) + ;; +*) + AC_MSG_WARN([No visibility checks for this compiler defined]) + ;; +esac + +AM_CONDITIONAL([COMPILER_GCC], [test "x${ax_cv_c_compiler_vendor}" = "xgnu"]) +AM_CONDITIONAL([COMPILER_SUNCC], [test "x${ax_cv_c_compiler_vendor}" = "xsun"]) + +AM_CONDITIONAL([HAVE_VISIBILITY], [test "x${HAVE_VISIBILITY}" = "xyes"]) +AM_CONDITIONAL([HAVE_VISIBILITY_INLINES_HIDDEN], [test "x${HAVE_VISIBILITY_INLINES_HIDDEN}" = "xyes"]) + +## +## pkgconfig based freeswitch detection code +## +AC_MSG_RESULT([${as_nl}<<>> FreeSWITCH environment]) + +PKG_CHECK_MODULES([freeswitch], [freeswitch], + [save_LIBS="${LIBS}" + save_CFLAGS="${CFLAGS}" + save_CPPFLAGS="${CPPFLAGS}" + + AC_MSG_CHECKING([FreeSWITCH version]) + + FREESWITCH_VERSION="`${PKG_CONFIG} --modversion freeswitch 2>/dev/null`" + AS_IF([test "x${FREESWITCH_VERSION}" = "x"], + [AC_MSG_ERROR([failed to get FreeSWITCH version])], + [AC_MSG_RESULT([$FREESWITCH_VERSION])] + ) + + AC_MSG_CHECKING([whether FreeSWITCH ${FREESWITCH_VERSION} is usable]) + CFLAGS="${freeswitch_CFLAGS}" + CPPFLAGS="${freeswitch_CPPFLAGS}" + LIBS="${freeswitch_LIBS}" + AC_TRY_LINK([#include ], + [switch_core_init(0, 0, NULL);], + [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no]) + AC_MSG_ERROR([libfreeswitch is unusable, please check config.log for details])] + ) + LIBS="${save_LIBS}" + CFLAGS="${save_CFLAGS}" + CPPFLAGS="${save_CPPFLAGS}" + + # get locations, critical first + AC_MSG_CHECKING([for installation prefix]) + FREESWITCH_PREFIX_DIR="`${PKG_CONFIG} --variable=prefix freeswitch 2>/dev/null`" + AS_IF( + [test "x${FREESWITCH_PREFIX_DIR}" = "x"], [AC_MSG_ERROR([unable to get FreeSWITCH prefix directory])], + [test ! -e "${FREESWITCH_PREFIX_DIR}"], [AC_MSG_ERROR([FreeSWITCH prefix directory ${FREESWITCH_PREFIX_DIR} does not exist])] + ) + AC_MSG_RESULT([${FREESWITCH_PREFIX_DIR}]) + + AC_MSG_CHECKING([for modules directory]) + FREESWITCH_MODULES_DIR="`${PKG_CONFIG} --variable=modulesdir freeswitch 2>/dev/null`" + AS_IF( + [test "x${FREESWITCH_MODULES_DIR}" = "x"], [AC_MSG_ERROR([unable to get FreeSWITCH modules directory])], + [test ! -e "${FREESWITCH_MODULES_DIR}"], [AC_MSG_ERROR([FreeSWITCH modules directory ${FREESWITCH_MODULES_DIR} does not exist])] + ) + AC_MSG_RESULT([${FREESWITCH_MODULES_DIR}]) + + AC_MSG_CHECKING([for configuration directory]) + FREESWITCH_CONFIG_DIR="`${PKG_CONFIG} --variable=sysconfdir freeswitch 2>/dev/null`" + AS_IF( + [test "x${FREESWITCH_CONFIG_DIR}" = "x"], [AC_MSG_ERROR([unable to get FreeSWITCH configuration directory])], + [test ! -e "${FREESWITCH_CONFIG_DIR}"], [AC_MSG_ERROR([FreeSWITCH configuration directory ${FREESWITCH_CONFIG_DIR} does not exist])] + ) + AC_MSG_RESULT([${FREESWITCH_CONFIG_DIR}]) + + # non-critical paths + FREESWITCH_HTDOCS_DIR="`${PKG_CONFIG} --variable=htdocsdir freeswitch 2>/dev/null`" + + FREESWITCH_RUNTIME_DIR="`${PKG_CONFIG} --variable=runtimedir freeswitch 2>/dev/null`" + FREESWITCH_SCRIPTS_DIR="`${PKG_CONFIG} --variable=scriptsdir freeswitch 2>/dev/null`" + + # cflags, libs + AC_SUBST([FREESWITCH_CFLAGS], [${freeswitch_CFLAGS}]) + AC_SUBST([FREESWITCH_CPPFLAGS], [${freeswitch_CPPFLAGS}]) + AC_SUBST([FREESWITCH_LIBS], [${freeswitch_LIBS}]) + + # version + AC_SUBST([FREESWITCH_VERSION]) + + # locations + AC_SUBST([FREESWITCH_PREFIX_DIR]) + AC_SUBST([FREESWITCH_HTDOCS_DIR]) + AC_SUBST([FREESWITCH_CONFIG_DIR]) + AC_SUBST([FREESWITCH_MODULES_DIR]) + AC_SUBST([FREESWITCH_SCRIPTS_DIR]) + AC_SUBST([FREESWITCH_RUNTIME_DIR]) + ], + [AC_MSG_ERROR([FreeSWITCH not found])] +) + +## +## Add your other dependency checks here +## +AC_MSG_RESULT([${as_nl}<<>> Other dependencies]) + +# Checks for header files. + +# Checks for typedefs, structures, and compiler characteristics. + +# Checks for library functions. + +AC_MSG_RESULT([${as_nl}<<>> Create output files]) +AC_CONFIG_FILES([Makefile src/Makefile]) +AC_OUTPUT + +AC_MSG_RESULT([ +====================== Configuration Summary ===================== ++ Package + Name:...................... ${PACKAGE_NAME} + Version:................... ${PACKAGE_VERSION} + Bugreports:................ ${PACKAGE_BUGREPORT} + Website:................... ${PACKAGE_URL} + ++ Compiler + Vendor:.................... ${ax_cv_c_compiler_vendor} + Symbol visibility:......... ${HAVE_VISIBILITY} + ++ FreeSWITCH + Version:................... ${FREESWITCH_VERSION} + Prefix:.................... ${FREESWITCH_PREFIX_DIR} + Modules directory:......... ${FREESWITCH_MODULES_DIR} + Configuration directory:... ${FREESWITCH_CONFIG_DIR} + + Cflags/CPPflags/CXXflags:.. ${FREESWITCH_CFLAGS} ${FREESWITCH_CPPFLAGS} + LDflags/Libs:.............. ${FREESWITCH_LIBS} ${FREESWITCH_LDFLAGS} + ++ Other + N/A +================================================================== +]) diff --git a/src/mod/sdk/autotools/m4/ax_compiler_vendor.m4 b/src/mod/sdk/autotools/m4/ax_compiler_vendor.m4 new file mode 100644 index 0000000000..a24a58da0f --- /dev/null +++ b/src/mod/sdk/autotools/m4/ax_compiler_vendor.m4 @@ -0,0 +1,15 @@ +AC_DEFUN([AX_COMPILER_VENDOR], +[ +AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor, + [ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=unknown + # note: don't check for gcc first since some other compilers define __GNUC__ + for ventest in intel:__ICC,__ECC,__INTEL_COMPILER ibm:__xlc__,__xlC__,__IBMC__,__IBMCPP__ gnu:__GNUC__ sun:__SUNPRO_C,__SUNPRO_CC hp:__HP_cc,__HP_aCC dec:__DECC,__DECCXX,__DECC_VER,__DECCXX_VER borland:__BORLANDC__,__TURBOC__ comeau:__COMO__ cray:_CRAYC kai:__KCC lcc:__LCC__ metrowerks:__MWERKS__ sgi:__sgi,sgi microsoft:_MSC_VER watcom:__WATCOMC__ portland:__PGI; do + vencpp="defined("`echo $ventest | cut -d: -f2 | sed 's/,/) || defined(/g'`")" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ +#if !($vencpp) + thisisanerror; +#endif +])], [ax_cv_]_AC_LANG_ABBREV[_compiler_vendor=`echo $ventest | cut -d: -f1`; break]) + done + ]) +]) diff --git a/src/mod/sdk/autotools/src/Makefile.am b/src/mod/sdk/autotools/src/Makefile.am new file mode 100644 index 0000000000..d2bad5bc80 --- /dev/null +++ b/src/mod/sdk/autotools/src/Makefile.am @@ -0,0 +1,66 @@ +moddir = @FREESWITCH_MODULES_DIR@ +sysconfdir = @FREESWITCH_CONFIG_DIR@ + +### +# Flags +# +AM_CFLAGS = +AM_CXXFLAGS= +AM_CPPFLAGS= -I. -I$(includedir) +AM_LDFLAGS = -L. -L$(libdir) -avoid-version -module -no-undefined -shared + +### +# GCC specific flags +# +if COMPILER_GCC +AM_CFLAGS += -Wall +# symbol visibility support +if HAVE_VISIBILITY +AM_CFLAGS += -fvisibility=hidden +AM_CXXFLAGS+= -fvisibility=hidden +AM_CPPFLAGS+= -DSWITCH_API_VISIBILITY=1 +endif +if HAVE_VISIBILITY_INLINES_HIDDEN +AM_CXXFLAGS += -fvisibility-inlines-hidden +endif +endif + +### +# SunCC specific flags +# +if COMPILER_SUNCC +AM_CFLAGS += +# symbol visibility support +if HAVE_VISIBILITY +AM_CFLAGS += -xldscope=hidden +AM_CXXFLAGS += -xldscope=hidden +AM_CPPFLAGS += -DSWITCH_API_VISIBILITY=1 +endif +endif + + +### +# add module(s) here, with suffix '.la' +# +mod_LTLIBRARIES = mod_example.la + +### +# mod_example +# +mod_example_la_SOURCES = mod_example.c +mod_example_la_CFLAGS = $(AM_CFLAGS) $(FREESWITCH_CFLAGS) +mod_example_la_CPPFLAGS= $(AM_CPPFLAGS) $(FREESWITCH_CPPFLAGS) +mod_example_la_LDFLAGS = $(AM_LDFLAGS) +mod_example_la_LIBADD = $(FREESWITCH_LIBS) + +# configuration file +#sysconf_DATA = example.conf.xml + +# +# install configuration +# +#install-sysconfDATA: +# $(INSTALL) -d $(DESTDIR)/$(sysconfdir) +# for x in $(sysconf_DATA); do \ +# test -e $(DESTDIR)$(sysconfdir)/$$x || $(INSTALL) -m644 $$x $(DESTDIR)$(sysconfdir)/$$x ; \ +# done diff --git a/src/mod/sdk/autotools/src/mod_example.c b/src/mod/sdk/autotools/src/mod_example.c new file mode 100644 index 0000000000..5e7755c752 --- /dev/null +++ b/src/mod/sdk/autotools/src/mod_example.c @@ -0,0 +1,84 @@ +/* + * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2005/2006, Anthony Minessale II + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * Anthony Minessale II + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Anthony Minessale II + * Neal Horman + * + * + * mod_example.c -- Framework Demo Module + * + */ +#include + +/* +SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_example_shutdown); +SWITCH_MODULE_RUNTIME_FUNCTION(mod_example_runtime); +*/ + +SWITCH_MODULE_LOAD_FUNCTION(mod_example_load); +SWITCH_MODULE_DEFINITION(mod_example, mod_example_load, NULL, NULL); + +SWITCH_MODULE_LOAD_FUNCTION(mod_example_load) +{ + /* connect my internal structure to the blank pointer passed to me */ + *module_interface = switch_loadable_module_create_module_interface(pool, modname); + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Hello World!\n"); + + /* indicate that the module should continue to be loaded */ + return SWITCH_STATUS_SUCCESS; +} + +/* + Called when the system shuts down +SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_example_shutdown); +{ + return SWITCH_STATUS_SUCCESS; +} +*/ + +/* + If it exists, this is called in it's own thread when the module-load completes + If it returns anything but SWITCH_STATUS_TERM it will be called again automaticly +SWITCH_MODULE_RUNTIME_FUNCTION(mod_example_runtime); +{ + while(looping) + { + switch_yield(1000); + } + return SWITCH_STATUS_TERM; +} +*/ + +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:nil + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab: + */ diff --git a/src/switch.c b/src/switch.c index c922d27ad0..33e7fb6336 100644 --- a/src/switch.c +++ b/src/switch.c @@ -404,7 +404,8 @@ int main(int argc, char *argv[]) #endif "\t-help -- this message\n" "\t-version -- print the version and exit\n" #ifdef HAVE_SETRLIMIT - "\t-waste -- allow memory waste\n" "\t-core -- dump cores\n" + "\t-waste -- allow memory waste\n" + "\t-core -- dump cores\n" #endif "\t-hp -- enable high priority settings\n" "\t-vg -- run under valgrind\n" @@ -552,6 +553,13 @@ int main(int argc, char *argv[]) } if (local_argv[x] && !strcmp(local_argv[x], "-waste")) { + fprintf(stderr, "WARNING: Wasting up to 8 megs of memory per thread.\n"); + sleep(2); + waste++; + known_opt++; + } + + if (local_argv[x] && !strcmp(local_argv[x], "-no-auto-stack")) { waste++; known_opt++; } @@ -771,8 +779,8 @@ int main(int argc, char *argv[]) char buf[1024] = ""; int i = 0; - fprintf(stderr, "Error: stacksize %d is too large: run ulimit -s %d or run %s -waste.\nauto-adjusting stack size for optimal performance...\n", - (int) (rlp.rlim_max / 1024), SWITCH_THREAD_STACKSIZE / 1024, local_argv[0]); + fprintf(stderr, "Error: stacksize %d is too large: run ulimit -s %d from your shell before starting the application.\nauto-adjusting stack size for optimal performance...\n", + (int) (rlp.rlim_max / 1024), SWITCH_THREAD_STACKSIZE / 1024); memset(&rlp, 0, sizeof(rlp)); rlp.rlim_cur = SWITCH_THREAD_STACKSIZE; diff --git a/src/switch_channel.c b/src/switch_channel.c index 9e3064b625..4341ea9214 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -1206,18 +1206,20 @@ SWITCH_DECLARE(void) switch_channel_wait_for_state(switch_channel_t *channel, sw } -SWITCH_DECLARE(void) switch_channel_wait_for_state_timeout(switch_channel_t *other_channel, switch_channel_state_t want_state, uint32_t timeout) +SWITCH_DECLARE(void) switch_channel_wait_for_state_timeout(switch_channel_t *channel, switch_channel_state_t want_state, uint32_t timeout) { switch_channel_state_t state; uint32_t count = 0; for (;;) { - state = switch_channel_get_running_state(other_channel); + state = switch_channel_get_running_state(channel); - if (state >= want_state) { + if ((channel->state == channel->running_state && channel->running_state == want_state) || channel->state >= CS_HANGUP) { break; } + switch_cond_next(); + if (++count >= timeout) { break; } @@ -2042,10 +2044,13 @@ SWITCH_DECLARE(void) switch_channel_event_set_extended_data(switch_channel_t *ch event->event_id == SWITCH_EVENT_REQUEST_PARAMS || event->event_id == SWITCH_EVENT_CHANNEL_DATA || event->event_id == SWITCH_EVENT_CHANNEL_EXECUTE_COMPLETE || + event->event_id == SWITCH_EVENT_CHANNEL_DESTROY || event->event_id == SWITCH_EVENT_SESSION_HEARTBEAT || event->event_id == SWITCH_EVENT_API || event->event_id == SWITCH_EVENT_RECORD_START || event->event_id == SWITCH_EVENT_RECORD_STOP || + event->event_id == SWITCH_EVENT_PLAYBACK_START || + event->event_id == SWITCH_EVENT_PLAYBACK_STOP || event->event_id == SWITCH_EVENT_CALL_UPDATE || event->event_id == SWITCH_EVENT_MEDIA_BUG_START || event->event_id == SWITCH_EVENT_MEDIA_BUG_STOP || diff --git a/src/switch_console.c b/src/switch_console.c index c5d601b9a2..a73bb58e89 100644 --- a/src/switch_console.c +++ b/src/switch_console.c @@ -252,7 +252,7 @@ SWITCH_DECLARE(char *) switch_console_expand_alias(char *cmd, char *arg) } - if (db->type == SCDB_TYPE_CORE_DB) { + if (switch_cache_db_get_type(db) == SCDB_TYPE_CORE_DB) { sql = switch_mprintf("select command from aliases where alias='%q'", cmd); } else { sql = switch_mprintf("select command from aliases where alias='%w'", cmd); @@ -268,7 +268,7 @@ SWITCH_DECLARE(char *) switch_console_expand_alias(char *cmd, char *arg) switch_safe_free(sql); if (!r) { - if (db->type == SCDB_TYPE_CORE_DB) { + if (switch_cache_db_get_type(db) == SCDB_TYPE_CORE_DB) { sql = switch_mprintf("select command from aliases where alias='%q %q'", cmd, arg); } else { sql = switch_mprintf("select command from aliases where alias='%w %w'", cmd, arg); @@ -794,7 +794,7 @@ SWITCH_DECLARE(unsigned char) switch_console_complete(const char *line, const ch stream.write_function(&stream, "select distinct a1 from complete where " "a1 not in (select name from interfaces where hostname='%s') %s ", switch_core_get_hostname(), argc ? "and" : ""); } else { - if (db->type == SCDB_TYPE_CORE_DB) { + if (switch_cache_db_get_type(db) == SCDB_TYPE_CORE_DB) { stream.write_function(&stream, "select distinct a%d,'%q','%q' from complete where ", h.words + 1, switch_str_nil(dup), switch_str_nil(lp)); } else { stream.write_function(&stream, "select distinct a%d,'%q','%w' from complete where ", h.words + 1, switch_str_nil(dup), switch_str_nil(lp)); @@ -803,7 +803,7 @@ SWITCH_DECLARE(unsigned char) switch_console_complete(const char *line, const ch for (x = 0; x < argc && x < 11; x++) { if (h.words + 1 > argc) { - if (db->type == SCDB_TYPE_CORE_DB) { + if (switch_cache_db_get_type(db) == SCDB_TYPE_CORE_DB) { stream.write_function(&stream, "(a%d like '::%%' or a%d = '' or a%d = '%q')%q", x + 1, x + 1, x + 1, switch_str_nil(argv[x]), x == argc - 1 ? "" : " and "); } else { @@ -811,7 +811,7 @@ SWITCH_DECLARE(unsigned char) switch_console_complete(const char *line, const ch x + 1, x + 1, x + 1, switch_str_nil(argv[x]), x == argc - 1 ? "" : " and "); } } else { - if (db->type == SCDB_TYPE_CORE_DB) { + if (switch_cache_db_get_type(db) == SCDB_TYPE_CORE_DB) { stream.write_function(&stream, "(a%d like '::%%' or a%d = '' or a%d like '%q%%')%q", x + 1, x + 1, x + 1, switch_str_nil(argv[x]), x == argc - 1 ? "" : " and "); } else { @@ -1765,6 +1765,11 @@ SWITCH_DECLARE(switch_status_t) switch_console_set_complete(const char *string) char *mydata = NULL, *argv[11] = { 0 }; int argc, x; switch_status_t status = SWITCH_STATUS_FALSE; + switch_core_flag_t cflags = switch_core_flags(); + + if (!(cflags & SCF_USE_SQL)) { + return SWITCH_STATUS_FALSE; + } if (string && (mydata = strdup(string))) { if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) { @@ -1787,7 +1792,7 @@ SWITCH_DECLARE(switch_status_t) switch_console_set_complete(const char *string) if (argv[x + 1] && !strcasecmp(argv[x + 1], "_any_")) { mystream.write_function(&mystream, "%s", "'', "); } else { - if (db->type == SCDB_TYPE_CORE_DB) { + if (switch_cache_db_get_type(db) == SCDB_TYPE_CORE_DB) { mystream.write_function(&mystream, "'%q', ", switch_str_nil(argv[x + 1])); } else { mystream.write_function(&mystream, "'%w', ", switch_str_nil(argv[x + 1])); @@ -1803,7 +1808,7 @@ SWITCH_DECLARE(switch_status_t) switch_console_set_complete(const char *string) if (argv[x + 1] && !strcasecmp(argv[x + 1], "_any_")) { mystream.write_function(&mystream, "%s", "'', "); } else { - if (db->type == SCDB_TYPE_CORE_DB) { + if (switch_cache_db_get_type(db) == SCDB_TYPE_CORE_DB) { mystream.write_function(&mystream, "'%q', ", switch_str_nil(argv[x + 1])); } else { mystream.write_function(&mystream, "'%w', ", switch_str_nil(argv[x + 1])); @@ -1821,7 +1826,7 @@ SWITCH_DECLARE(switch_status_t) switch_console_set_complete(const char *string) } else { mystream.write_function(&mystream, "delete from complete where "); for (x = 0; x < argc - 1; x++) { - if (db->type == SCDB_TYPE_CORE_DB) { + if (switch_cache_db_get_type(db) == SCDB_TYPE_CORE_DB) { mystream.write_function(&mystream, "a%d = '%q'%q", x + 1, switch_str_nil(argv[x + 1]), x == argc - 2 ? "" : " and "); } else { mystream.write_function(&mystream, "a%d = '%w'%w", x + 1, switch_str_nil(argv[x + 1]), x == argc - 2 ? "" : " and "); @@ -1866,7 +1871,7 @@ SWITCH_DECLARE(switch_status_t) switch_console_set_alias(const char *string) sql = switch_mprintf("delete from aliases where alias='%q' and hostname='%q'", argv[1], switch_core_get_hostname()); switch_cache_db_persistant_execute(db, sql, 5); switch_safe_free(sql); - if (db->type == SCDB_TYPE_CORE_DB) { + if (switch_cache_db_get_type(db) == SCDB_TYPE_CORE_DB) { sql = switch_mprintf("insert into aliases (sticky, alias, command, hostname) values (1, '%q','%q','%q')", argv[1], argv[2], switch_core_get_hostname()); } else { @@ -1879,7 +1884,7 @@ SWITCH_DECLARE(switch_status_t) switch_console_set_alias(const char *string) sql = switch_mprintf("delete from aliases where alias='%q' and hostname='%q'", argv[1], switch_core_get_hostname()); switch_cache_db_persistant_execute(db, sql, 5); switch_safe_free(sql); - if (db->type == SCDB_TYPE_CORE_DB) { + if (switch_cache_db_get_type(db) == SCDB_TYPE_CORE_DB) { sql = switch_mprintf("insert into aliases (sticky, alias, command, hostname) values (0, '%q','%q','%q')", argv[1], argv[2], switch_core_get_hostname()); } else { diff --git a/src/switch_core.c b/src/switch_core.c index 5479229100..96e4b4ae27 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -98,10 +98,9 @@ static void check_ip(void) char old_ip6[256] = ""; int ok4 = 1, ok6 = 1; int mask = 0; - static char hostname[256] = ""; - gethostname(hostname, sizeof(hostname)); - switch_core_set_variable("hostname", hostname); + gethostname(runtime.hostname, sizeof(runtime.hostname)); + switch_core_set_variable("hostname", runtime.hostname); switch_find_local_ip(guess_ip4, sizeof(guess_ip4), &mask, AF_INET); switch_find_local_ip(guess_ip6, sizeof(guess_ip6), NULL, AF_INET6); @@ -1280,7 +1279,13 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc /* one per customer */ return SWITCH_STATUS_SUCCESS; } + + memset(&runtime, 0, sizeof(runtime)); + gethostname(runtime.hostname, sizeof(runtime.hostname)); + runtime.max_db_handles = 50; + runtime.db_handle_timeout = 5000000;; + runtime.runlevel++; runtime.sql_buffer_len = 1024 * 32; runtime.max_sql_buffer_len = 1024 * 1024; @@ -1348,9 +1353,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc runtime.console = stdout; } - gethostname(runtime.hostname, sizeof(runtime.hostname)); switch_core_set_variable("hostname", runtime.hostname); - switch_find_local_ip(guess_ip, sizeof(guess_ip), &mask, AF_INET); switch_core_set_variable("local_ip_v4", guess_ip); in.s_addr = mask; @@ -1549,6 +1552,23 @@ static void switch_load_core_config(const char *file) if (tmp > -1 && tmp < 11) { switch_core_session_ctl(SCSC_DEBUG_LEVEL, &tmp); } + } else if (!strcasecmp(var, "max-db-handles")) { + long tmp = atol(val); + + if (tmp > 4 && tmp < 5001) { + runtime.max_db_handles = (uint32_t) tmp; + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "max-db-handles must be between 5 and 5000\n"); + } + } else if (!strcasecmp(var, "db-handle-timeout")) { + long tmp = atol(val); + + if (tmp > 0 && tmp < 5001) { + runtime.db_handle_timeout = (uint32_t) tmp * 1000000; + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "db-handle-timeout must be between 1 and 5000\n"); + } + } else if (!strcasecmp(var, "multiple-registrations")) { runtime.multiple_registrations = switch_true(val); } else if (!strcasecmp(var, "sql-buffer-len")) { diff --git a/src/switch_core_db.c b/src/switch_core_db.c index b3cd2ceff8..c64629c32b 100644 --- a/src/switch_core_db.c +++ b/src/switch_core_db.c @@ -94,7 +94,7 @@ SWITCH_DECLARE(int) switch_core_db_exec(switch_core_db_t *db, const char *sql, s if (ret == SQLITE_BUSY || ret == SQLITE_LOCKED) { if (sane > 1) { switch_core_db_free(err); - switch_yield(100000); + switch_yield(1000); /* Was 100000. I think it's too much */ continue; } } else { @@ -182,9 +182,27 @@ SWITCH_DECLARE(switch_core_db_t *) switch_core_db_open_file(const char *filename { switch_core_db_t *db; char path[1024]; + int db_ret; db_pick_path(filename, path, sizeof(path)); - if (switch_core_db_open(path, &db)) { + if ((db_ret = switch_core_db_open(path, &db)) != SQLITE_OK) { + goto end; + } + if ((db_ret = switch_core_db_exec(db, "PRAGMA synchronous=OFF;", NULL, NULL, NULL) != SQLITE_OK)) { + goto end; + } + if ((db_ret = switch_core_db_exec(db, "PRAGMA count_changes=OFF;", NULL, NULL, NULL) != SQLITE_OK)) { + goto end; + } + if ((db_ret = switch_core_db_exec(db, "PRAGMA cache_size=8000;", NULL, NULL, NULL) != SQLITE_OK)) { + goto end; + } + if ((db_ret = switch_core_db_exec(db, "PRAGMA temp_store=MEMORY;", NULL, NULL, NULL) != SQLITE_OK)) { + goto end; + } + +end: + if (db_ret != SQLITE_OK) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL ERR [%s]\n", switch_core_db_errmsg(db)); switch_core_db_close(db); db = NULL; diff --git a/src/switch_core_io.c b/src/switch_core_io.c index 4e1c7075b5..14cec65808 100644 --- a/src/switch_core_io.c +++ b/src/switch_core_io.c @@ -310,6 +310,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi } else { memset(session->raw_read_frame.data, 255, read_frame->codec->implementation->decoded_bytes_per_packet); } + + session->raw_read_frame.timestamp = 0; session->raw_read_frame.datalen = read_frame->codec->implementation->decoded_bytes_per_packet; session->raw_read_frame.samples = session->raw_read_frame.datalen / sizeof(int16_t); read_frame = &session->raw_read_frame; diff --git a/src/switch_core_memory.c b/src/switch_core_memory.c index dd87f8f4a2..7e6abf9c77 100644 --- a/src/switch_core_memory.c +++ b/src/switch_core_memory.c @@ -409,9 +409,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_perform_new_memory_pool(switch_memor SWITCH_DECLARE(switch_status_t) switch_core_perform_destroy_memory_pool(switch_memory_pool_t **pool, const char *file, const char *func, int line) { switch_assert(pool != NULL); - if (switch_core_memory_pool_get_data(*pool, "_in_thread")) { - switch_cache_db_detach(); - } + #ifdef DEBUG_ALLOC2 switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "Free Pool\n"); #endif diff --git a/src/switch_core_session.c b/src/switch_core_session.c index d2e28de523..2080c0b624 100644 --- a/src/switch_core_session.c +++ b/src/switch_core_session.c @@ -203,16 +203,12 @@ SWITCH_DECLARE(void) switch_core_session_hupall_matching_var(const char *var_nam for (hi = switch_hash_first(NULL, session_manager.session_table); hi; hi = switch_hash_next(hi)) { switch_hash_this(hi, NULL, NULL, &val); if (val) { - const char *this_val; session = (switch_core_session_t *) val; if (switch_core_session_read_lock(session) == SWITCH_STATUS_SUCCESS) { - if (switch_channel_up(session->channel) && - (this_val = switch_channel_get_variable(session->channel, var_name)) && (!strcmp(this_val, var_val))) { - np = switch_core_alloc(pool, sizeof(*np)); - np->str = switch_core_strdup(pool, session->uuid_str); - np->next = head; - head = np; - } + np = switch_core_alloc(pool, sizeof(*np)); + np->str = switch_core_strdup(pool, session->uuid_str); + np->next = head; + head = np; switch_core_session_rwunlock(session); } } @@ -221,7 +217,11 @@ SWITCH_DECLARE(void) switch_core_session_hupall_matching_var(const char *var_nam for(np = head; np; np = np->next) { if ((session = switch_core_session_locate(np->str))) { - switch_channel_hangup(session->channel, cause); + const char *this_val; + if (switch_channel_up(session->channel) && + (this_val = switch_channel_get_variable(session->channel, var_name)) && (!strcmp(this_val, var_val))) { + switch_channel_hangup(session->channel, cause); + } switch_core_session_rwunlock(session); } } @@ -1947,7 +1947,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_execute_application_get_flag do { sanity--; - ready = switch_channel_media_ready(session->channel); + ready = switch_channel_media_up(session->channel); switch_cond_next(); } while(!ready && sanity); diff --git a/src/switch_core_sqldb.c b/src/switch_core_sqldb.c index 1274213893..a4ed5ca83c 100644 --- a/src/switch_core_sqldb.c +++ b/src/switch_core_sqldb.c @@ -36,6 +36,21 @@ #include "private/switch_core_pvt.h" //*#define DEBUG_SQL 1 +struct switch_cache_db_handle { + char name[CACHE_DB_LEN]; + switch_cache_db_handle_type_t type; + switch_cache_db_native_handle_t native_handle; + time_t last_used; + switch_mutex_t *mutex; + switch_mutex_t *io_mutex; + switch_memory_pool_t *pool; + int32_t flags; + unsigned long hash; + char creator[CACHE_DB_LEN]; + char last_user[CACHE_DB_LEN]; + struct switch_cache_db_handle *next; +}; + static struct { switch_cache_db_handle_t *event_db; switch_queue_t *sql_queue[2]; @@ -48,12 +63,77 @@ static struct { switch_bool_t manage; switch_mutex_t *io_mutex; switch_mutex_t *dbh_mutex; - switch_hash_t *dbh_hash; + switch_cache_db_handle_t *handle_pool; switch_thread_cond_t *cond; switch_mutex_t *cond_mutex; + uint32_t total_handles; + uint32_t total_used_handles; } sql_manager; +static void add_handle(switch_cache_db_handle_t *dbh) +{ + switch_mutex_lock(sql_manager.dbh_mutex); + switch_set_flag(dbh, CDF_INUSE); + sql_manager.total_used_handles++; + dbh->next = sql_manager.handle_pool; + sql_manager.handle_pool = dbh; + sql_manager.total_handles++; + switch_mutex_lock(dbh->mutex); + switch_mutex_unlock(sql_manager.dbh_mutex); +} + +static void del_handle(switch_cache_db_handle_t *dbh) +{ + switch_cache_db_handle_t *dbhp, *last = NULL; + + switch_mutex_lock(sql_manager.dbh_mutex); + for (dbhp = sql_manager.handle_pool; dbhp; dbhp = dbhp->next) { + if (dbhp == dbh) { + if (last) { + last->next = dbhp->next; + } else { + sql_manager.handle_pool = dbhp->next; + } + sql_manager.total_handles--; + break; + } + + last = dbhp; + } + switch_mutex_unlock(sql_manager.dbh_mutex); +} + +static switch_cache_db_handle_t *get_handle(const char *db_str, const char *user_str) +{ + switch_ssize_t hlen = -1; + unsigned long hash = 0; + switch_cache_db_handle_t *dbhp, *r = NULL; + + + hash = switch_ci_hashfunc_default(db_str, &hlen); + + switch_mutex_lock(sql_manager.dbh_mutex); + for (dbhp = sql_manager.handle_pool; dbhp; dbhp = dbhp->next) { + if (dbhp->hash == hash && !switch_test_flag(dbhp, CDF_INUSE) && + !switch_test_flag(dbhp, CDF_PRUNE) && switch_mutex_trylock(dbhp->mutex) == SWITCH_STATUS_SUCCESS) { + r = dbhp; + + switch_set_flag(dbhp, CDF_INUSE); + sql_manager.total_used_handles++; + dbhp->hash = switch_ci_hashfunc_default(db_str, &hlen); + switch_set_string(dbhp->last_user, user_str); + + break; + } + } + switch_mutex_unlock(sql_manager.dbh_mutex); + + return r; + +} + + #define SWITCH_CORE_DB "core" /*! \brief Open the default system database @@ -93,62 +173,56 @@ SWITCH_DECLARE(switch_status_t) _switch_core_db_handle(switch_cache_db_handle_t #define SQL_CACHE_TIMEOUT 120 #define SQL_REG_TIMEOUT 15 + static void sql_close(time_t prune) { - switch_hash_index_t *hi; - const void *var; - void *val; switch_cache_db_handle_t *dbh = NULL; int locked = 0; - char *key; switch_mutex_lock(sql_manager.dbh_mutex); top: locked = 0; - for (hi = switch_hash_first(NULL, sql_manager.dbh_hash); hi; hi = switch_hash_next(hi)) { - switch_hash_this(hi, &var, NULL, &val); - key = (char *) var; + for (dbh = sql_manager.handle_pool; dbh; dbh = dbh->next) { + time_t diff = 0; - if ((dbh = (switch_cache_db_handle_t *) val)) { - time_t diff = 0; - - if (prune > 0 && prune > dbh->last_used) { - diff = (time_t) prune - dbh->last_used; - } - - if (prune > 0 && diff < SQL_CACHE_TIMEOUT && !switch_test_flag(dbh, CDF_PRUNE)) { - continue; - } - - if (switch_mutex_trylock(dbh->mutex) == SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "Dropping idle DB connection %s\n", key); - - switch (dbh->type) { - case SCDB_TYPE_ODBC: - { - switch_odbc_handle_destroy(&dbh->native_handle.odbc_dbh); - } - break; - case SCDB_TYPE_CORE_DB: - { - switch_core_db_close(dbh->native_handle.core_db_dbh); - dbh->native_handle.core_db_dbh = NULL; - } - break; - } - - switch_core_hash_delete(sql_manager.dbh_hash, key); - switch_mutex_unlock(dbh->mutex); - switch_core_destroy_memory_pool(&dbh->pool); - goto top; - - } else { - if (!prune) - locked++; - continue; - } + if (prune > 0 && prune > dbh->last_used) { + diff = (time_t) prune - dbh->last_used; } + + if (prune > 0 && (switch_test_flag(dbh, CDF_INUSE) || (diff < SQL_CACHE_TIMEOUT && !switch_test_flag(dbh, CDF_PRUNE)))) { + continue; + } + + if (switch_mutex_trylock(dbh->mutex) == SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "Dropping idle DB connection %s\n", dbh->name); + + switch (dbh->type) { + case SCDB_TYPE_ODBC: + { + switch_odbc_handle_destroy(&dbh->native_handle.odbc_dbh); + } + break; + case SCDB_TYPE_CORE_DB: + { + switch_core_db_close(dbh->native_handle.core_db_dbh); + dbh->native_handle.core_db_dbh = NULL; + } + break; + } + + del_handle(dbh); + switch_mutex_unlock(dbh->mutex); + switch_core_destroy_memory_pool(&dbh->pool); + goto top; + + } else { + if (!prune) { + locked++; + } + continue; + } + } if (locked) { @@ -159,135 +233,69 @@ static void sql_close(time_t prune) } +SWITCH_DECLARE(switch_cache_db_handle_type_t) switch_cache_db_get_type(switch_cache_db_handle_t *dbh) +{ + return dbh->type; +} + SWITCH_DECLARE(void) switch_cache_db_flush_handles(void) { sql_close(switch_epoch_time_now(NULL) + SQL_CACHE_TIMEOUT + 1); } - SWITCH_DECLARE(void) switch_cache_db_release_db_handle(switch_cache_db_handle_t **dbh) { if (dbh && *dbh) { - - switch ((*dbh)->type) { - case SCDB_TYPE_ODBC: - { - switch_clear_flag((*dbh), CDF_INUSE); - } - break; - default: - break; - } - + switch_mutex_lock(sql_manager.dbh_mutex); + (*dbh)->last_used = switch_epoch_time_now(NULL); + switch_clear_flag((*dbh), CDF_INUSE); switch_mutex_unlock((*dbh)->mutex); + sql_manager.total_used_handles--; *dbh = NULL; + switch_mutex_unlock(sql_manager.dbh_mutex); } } SWITCH_DECLARE(void) switch_cache_db_dismiss_db_handle(switch_cache_db_handle_t **dbh) { - if (dbh && *dbh) { - - if ((*dbh)->type == SCDB_TYPE_CORE_DB) { - switch_set_flag((*dbh), CDF_PRUNE); - } else { - switch_clear_flag((*dbh), CDF_INUSE); - } - - switch_mutex_unlock((*dbh)->mutex); - *dbh = NULL; - } + switch_cache_db_release_db_handle(dbh); } -SWITCH_DECLARE(void) switch_cache_db_destroy_db_handle(switch_cache_db_handle_t **dbh) -{ - if (dbh && *dbh) { - switch_mutex_lock(sql_manager.dbh_mutex); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "Deleting DB connection %s\n", (*dbh)->name); - - switch ((*dbh)->type) { - case SCDB_TYPE_ODBC: - { - switch_odbc_handle_destroy(&(*dbh)->native_handle.odbc_dbh); - } - break; - case SCDB_TYPE_CORE_DB: - { - switch_core_db_close((*dbh)->native_handle.core_db_dbh); - (*dbh)->native_handle.core_db_dbh = NULL; - } - break; - } - - - switch_core_hash_delete(sql_manager.dbh_hash, (*dbh)->name); - switch_mutex_unlock((*dbh)->mutex); - switch_core_destroy_memory_pool(&(*dbh)->pool); - *dbh = NULL; - switch_mutex_unlock(sql_manager.dbh_mutex); - } -} - -SWITCH_DECLARE(void) switch_cache_db_detach(void) -{ - char thread_str[CACHE_DB_LEN] = ""; - switch_hash_index_t *hi; - const void *var; - void *val; - char *key; - switch_cache_db_handle_t *dbh = NULL; - int prune = 0; - - snprintf(thread_str, sizeof(thread_str) - 1, "%lu", (unsigned long) (intptr_t) switch_thread_self()); - switch_mutex_lock(sql_manager.dbh_mutex); - - for (hi = switch_hash_first(NULL, sql_manager.dbh_hash); hi; hi = switch_hash_next(hi)) { - switch_hash_this(hi, &var, NULL, &val); - key = (char *) var; - if ((dbh = (switch_cache_db_handle_t *) val)) { - if (switch_mutex_trylock(dbh->mutex) == SWITCH_STATUS_SUCCESS) { - if (strstr(dbh->name, thread_str)) { - if (dbh->type == SCDB_TYPE_CORE_DB) { - switch_set_flag(dbh, CDF_PRUNE); - prune++; - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, - "Detach cached DB handle %s [%s]\n", thread_str, switch_cache_db_type_name(dbh->type)); - switch_clear_flag(dbh, CDF_INUSE); - } - } - switch_mutex_unlock(dbh->mutex); - } - } - } - - switch_mutex_unlock(sql_manager.dbh_mutex); - - if (prune) { - sql_close(switch_epoch_time_now(NULL)); - } - -} - SWITCH_DECLARE(switch_status_t) _switch_cache_db_get_db_handle(switch_cache_db_handle_t **dbh, switch_cache_db_handle_type_t type, switch_cache_db_connection_options_t *connection_options, const char *file, const char *func, int line) { - switch_thread_id_t self = switch_thread_self(); - char thread_str[CACHE_DB_LEN] = ""; char db_str[CACHE_DB_LEN] = ""; char db_callsite_str[CACHE_DB_LEN] = ""; switch_cache_db_handle_t *new_dbh = NULL; switch_ssize_t hlen = -1; + int waiting = 0; + uint32_t yield_len = 100000, total_yield = 0; const char *db_name = NULL; const char *db_user = NULL; const char *db_pass = NULL; + while(runtime.max_db_handles && sql_manager.total_handles >= runtime.max_db_handles && sql_manager.total_used_handles >= sql_manager.total_handles) { + if (!waiting++) { + switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_WARNING, "Max handles %u exceeded, blocking....\n", + runtime.max_db_handles); + } + + switch_yield(yield_len); + total_yield += yield_len; + + if (runtime.db_handle_timeout && total_yield > runtime.db_handle_timeout) { + switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_ERROR, "Error connecting\n"); + *dbh = NULL; + return SWITCH_STATUS_FALSE; + } + } + switch (type) { case SCDB_TYPE_ODBC: { @@ -310,45 +318,13 @@ SWITCH_DECLARE(switch_status_t) _switch_cache_db_get_db_handle(switch_cache_db_h } snprintf(db_str, sizeof(db_str) - 1, "db=\"%s\";user=\"%s\";pass=\"%s\"", db_name, db_user, db_pass); - snprintf(thread_str, sizeof(thread_str) - 1, "%s;thread=\"%lu\"", db_str, (unsigned long) (intptr_t) self); snprintf(db_callsite_str, sizeof(db_callsite_str) - 1, "%s:%d", file, line); - switch_mutex_lock(sql_manager.dbh_mutex); - if ((new_dbh = switch_core_hash_find(sql_manager.dbh_hash, thread_str))) { - switch_set_string(new_dbh->last_user, db_callsite_str); + + if ((new_dbh = get_handle(db_str, db_callsite_str))) { switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG10, - "Reuse Cached DB handle %s [%s]\n", thread_str, switch_cache_db_type_name(new_dbh->type)); + "Reuse Unused Cached DB handle %s [%s]\n", new_dbh->name, switch_cache_db_type_name(new_dbh->type)); } else { - switch_hash_index_t *hi; - const void *var; - void *val; - char *key; - unsigned long hash = 0; - - hash = switch_ci_hashfunc_default(db_str, &hlen); - - for (hi = switch_hash_first(NULL, sql_manager.dbh_hash); hi; hi = switch_hash_next(hi)) { - switch_hash_this(hi, &var, NULL, &val); - key = (char *) var; - - if ((new_dbh = (switch_cache_db_handle_t *) val)) { - if (hash == new_dbh->hash && !strncasecmp(new_dbh->name, db_str, strlen(db_str)) && - !switch_test_flag(new_dbh, CDF_INUSE) && !switch_test_flag(new_dbh, CDF_PRUNE) - && switch_mutex_trylock(new_dbh->mutex) == SWITCH_STATUS_SUCCESS) { - switch_set_flag(new_dbh, CDF_INUSE); - switch_set_string(new_dbh->name, thread_str); - new_dbh->hash = switch_ci_hashfunc_default(db_str, &hlen); - switch_set_string(new_dbh->last_user, db_callsite_str); - switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG10, - "Reuse Unused Cached DB handle %s [%s]\n", thread_str, switch_cache_db_type_name(new_dbh->type)); - break; - } - } - new_dbh = NULL; - } - } - - if (!new_dbh) { switch_memory_pool_t *pool = NULL; switch_core_db_t *db = NULL; switch_odbc_handle_t *odbc_dbh = NULL; @@ -388,17 +364,15 @@ SWITCH_DECLARE(switch_status_t) _switch_cache_db_get_db_handle(switch_cache_db_h } switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG10, - "Create Cached DB handle %s [%s]\n", thread_str, switch_cache_db_type_name(type)); + "Create Cached DB handle %s [%s] %s:%d\n", new_dbh->name, switch_cache_db_type_name(type), file, line); switch_core_new_memory_pool(&pool); new_dbh = switch_core_alloc(pool, sizeof(*new_dbh)); new_dbh->pool = pool; new_dbh->type = type; - switch_set_string(new_dbh->name, thread_str); - switch_set_flag(new_dbh, CDF_INUSE); + switch_set_string(new_dbh->name, db_str); new_dbh->hash = switch_ci_hashfunc_default(db_str, &hlen); - if (db) { new_dbh->native_handle.core_db_dbh = db; } else { @@ -407,9 +381,7 @@ SWITCH_DECLARE(switch_status_t) _switch_cache_db_get_db_handle(switch_cache_db_h switch_mutex_init(&new_dbh->mutex, SWITCH_MUTEX_UNNESTED, new_dbh->pool); switch_set_string(new_dbh->creator, db_callsite_str); - switch_mutex_lock(new_dbh->mutex); - - switch_core_hash_insert(sql_manager.dbh_hash, new_dbh->name, new_dbh); + add_handle(new_dbh); } end: @@ -417,9 +389,7 @@ SWITCH_DECLARE(switch_status_t) _switch_cache_db_get_db_handle(switch_cache_db_h if (new_dbh) { new_dbh->last_used = switch_epoch_time_now(NULL); } - - switch_mutex_unlock(sql_manager.dbh_mutex); - + *dbh = new_dbh; return *dbh ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE; @@ -431,13 +401,13 @@ static switch_status_t switch_cache_db_execute_sql_real(switch_cache_db_handle_t switch_status_t status = SWITCH_STATUS_FALSE; char *errmsg = NULL; char *tmp = NULL; + switch_mutex_t *io_mutex = dbh->io_mutex; + + if (io_mutex) switch_mutex_lock(io_mutex); - if (dbh->io_mutex) { - switch_mutex_lock(dbh->io_mutex); - } - - if (err) + if (err) { *err = NULL; + } switch (dbh->type) { case SCDB_TYPE_ODBC: @@ -469,9 +439,7 @@ static switch_status_t switch_cache_db_execute_sql_real(switch_cache_db_handle_t } - if (dbh->io_mutex) { - switch_mutex_unlock(dbh->io_mutex); - } + if (io_mutex) switch_mutex_unlock(io_mutex); return status; } @@ -556,10 +524,9 @@ static switch_status_t switch_cache_db_execute_sql_chunked(switch_cache_db_handl SWITCH_DECLARE(switch_status_t) switch_cache_db_execute_sql(switch_cache_db_handle_t *dbh, char *sql, char **err) { switch_status_t status = SWITCH_STATUS_FALSE; + switch_mutex_t *io_mutex = dbh->io_mutex; - if (dbh->io_mutex) { - switch_mutex_lock(dbh->io_mutex); - } + if (io_mutex) switch_mutex_lock(io_mutex); switch (dbh->type) { default: @@ -569,9 +536,7 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_execute_sql(switch_cache_db_hand break; } - if (dbh->io_mutex) { - switch_mutex_unlock(dbh->io_mutex); - } + if (io_mutex) switch_mutex_unlock(io_mutex); return status; @@ -599,11 +564,9 @@ SWITCH_DECLARE(int) switch_cache_db_affected_rows(switch_cache_db_handle_t *dbh) SWITCH_DECLARE(char *) switch_cache_db_execute_sql2str(switch_cache_db_handle_t *dbh, char *sql, char *str, size_t len, char **err) { switch_status_t status = SWITCH_STATUS_FALSE; + switch_mutex_t *io_mutex = dbh->io_mutex; - - if (dbh->io_mutex) { - switch_mutex_lock(dbh->io_mutex); - } + if (io_mutex) switch_mutex_lock(io_mutex); switch (dbh->type) { case SCDB_TYPE_CORE_DB: @@ -612,7 +575,7 @@ SWITCH_DECLARE(char *) switch_cache_db_execute_sql2str(switch_cache_db_handle_t if (switch_core_db_prepare(dbh->native_handle.core_db_dbh, sql, -1, &stmt, 0)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Statement Error [%s]!\n", sql); - return NULL; + goto end; } else { int running = 1; int colcount; @@ -652,9 +615,7 @@ SWITCH_DECLARE(char *) switch_cache_db_execute_sql2str(switch_cache_db_handle_t end: - if (dbh->io_mutex) { - switch_mutex_unlock(dbh->io_mutex); - } + if (io_mutex) switch_mutex_unlock(io_mutex); return status == SWITCH_STATUS_SUCCESS ? str : NULL; @@ -665,18 +626,20 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute(switch_cache_ char *errmsg = NULL; switch_status_t status = SWITCH_STATUS_FALSE; uint8_t forever = 0; + switch_mutex_t *io_mutex = dbh->io_mutex; if (!retries) { forever = 1; retries = 1000; } - if (dbh->io_mutex) { - switch_mutex_lock(dbh->io_mutex); - } - while (retries > 0) { + + if (io_mutex) switch_mutex_lock(io_mutex); switch_cache_db_execute_sql_real(dbh, sql, &errmsg); + if (io_mutex) switch_mutex_unlock(io_mutex); + + if (errmsg) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL ERR [%s]\n", errmsg); switch_safe_free(errmsg); @@ -691,11 +654,7 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute(switch_cache_ break; } } - - if (dbh->io_mutex) { - switch_mutex_unlock(dbh->io_mutex); - } - + return status; } @@ -707,15 +666,14 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute_trans(switch_ uint8_t forever = 0; unsigned begin_retries = 100; uint8_t again = 0; + switch_mutex_t *io_mutex = dbh->io_mutex; if (!retries) { forever = 1; retries = 1000; } - if (dbh->io_mutex) { - switch_mutex_lock(dbh->io_mutex); - } + if (io_mutex) switch_mutex_lock(io_mutex); again: @@ -726,6 +684,7 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute_trans(switch_ switch_cache_db_execute_sql_real(dbh, "BEGIN", &errmsg); } else { switch_odbc_status_t result; + if ((result = switch_odbc_SQLSetAutoCommitAttr(dbh->native_handle.odbc_dbh, 0)) != SWITCH_ODBC_SUCCESS) { char tmp[100]; switch_snprintf(tmp, sizeof(tmp), "%s-%i", "Unable to Set AutoCommit Off", result); @@ -753,23 +712,23 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute_trans(switch_ goto again; } - + switch_yield(100000); if (begin_retries == 0) { goto done; } - } else { - break; + + continue; } + break; } while (retries > 0) { switch_cache_db_execute_sql(dbh, sql, &errmsg); - if (errmsg) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL ERR [%s]\n", errmsg); free(errmsg); @@ -795,10 +754,7 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute_trans(switch_ switch_odbc_SQLSetAutoCommitAttr(dbh->native_handle.odbc_dbh, 1); } - if (dbh->io_mutex) { - switch_mutex_unlock(dbh->io_mutex); - } - + if (io_mutex) switch_mutex_unlock(io_mutex); return status; } @@ -808,14 +764,14 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_execute_sql_callback(switch_cach { switch_status_t status = SWITCH_STATUS_FALSE; char *errmsg = NULL; + switch_mutex_t *io_mutex = dbh->io_mutex; - if (err) + if (err) { *err = NULL; - - if (dbh->io_mutex) { - switch_mutex_lock(dbh->io_mutex); } + if (io_mutex) switch_mutex_lock(io_mutex); + switch (dbh->type) { case SCDB_TYPE_ODBC: @@ -829,16 +785,16 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_execute_sql_callback(switch_cach if (errmsg) { dbh->last_used = switch_epoch_time_now(NULL) - (SQL_CACHE_TIMEOUT * 2); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL ERR: [%s] %s\n", sql, errmsg); + if (!strstr(errmsg, "query abort")) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL ERR: [%s] %s\n", sql, errmsg); + } switch_core_db_free(errmsg); } } break; } - if (dbh->io_mutex) { - switch_mutex_unlock(dbh->io_mutex); - } + if (io_mutex) switch_mutex_unlock(io_mutex); return status; } @@ -848,15 +804,14 @@ SWITCH_DECLARE(switch_bool_t) switch_cache_db_test_reactive(switch_cache_db_hand { char *errmsg; switch_bool_t r = SWITCH_TRUE; + switch_mutex_t *io_mutex = dbh->io_mutex; if (!switch_test_flag((&runtime), SCF_AUTO_SCHEMAS)) { switch_cache_db_execute_sql(dbh, (char *)test_sql, NULL); return SWITCH_TRUE; } - if (dbh->io_mutex) { - switch_mutex_lock(dbh->io_mutex); - } + if (io_mutex) switch_mutex_lock(io_mutex); switch (dbh->type) { case SCDB_TYPE_ODBC: @@ -901,9 +856,7 @@ SWITCH_DECLARE(switch_bool_t) switch_cache_db_test_reactive(switch_cache_db_hand } - if (dbh->io_mutex) { - switch_mutex_unlock(dbh->io_mutex); - } + if (io_mutex) switch_mutex_unlock(io_mutex); return r; } @@ -922,7 +875,7 @@ static void *SWITCH_THREAD_FUNC switch_core_sql_db_thread(switch_thread_t *threa sec = 0; } - if (++reg_sec == SQL_REG_TIMEOUT) { + if (switch_test_flag((&runtime), SCF_USE_SQL) && ++reg_sec == SQL_REG_TIMEOUT) { switch_core_expire_registration(0); reg_sec = 0; } @@ -1648,6 +1601,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_add_registration(const char *user, c switch_cache_db_handle_t *dbh; char *sql; + if (!switch_test_flag((&runtime), SCF_USE_SQL)) { + return SWITCH_STATUS_FALSE; + } + if (switch_core_db_handle(&dbh) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB!\n"); return SWITCH_STATUS_FALSE; @@ -1691,12 +1648,20 @@ SWITCH_DECLARE(switch_status_t) switch_core_del_registration(const char *user, c switch_cache_db_handle_t *dbh; char *sql; + if (!switch_test_flag((&runtime), SCF_USE_SQL)) { + return SWITCH_STATUS_FALSE; + } + if (switch_core_db_handle(&dbh) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB!\n"); return SWITCH_STATUS_FALSE; } - sql = switch_mprintf("delete from registrations where reg_user='%q' and realm='%q' and hostname='%q'", user, realm, switch_core_get_hostname()); + if (!zstr(token) && runtime.multiple_registrations) { + sql = switch_mprintf("delete from registrations where reg_user='%q' and realm='%q' and hostname='%q' and token='%q'", user, realm, switch_core_get_hostname(), token); + } else { + sql = switch_mprintf("delete from registrations where reg_user='%q' and realm='%q' and hostname='%q'", user, realm, switch_core_get_hostname()); + } switch_cache_db_execute_sql(dbh, sql, NULL); switch_cache_db_release_db_handle(&dbh); @@ -1713,6 +1678,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_expire_registration(int force) char *sql; switch_time_t now; + if (!switch_test_flag((&runtime), SCF_USE_SQL)) { + return SWITCH_STATUS_FALSE; + } + if (switch_core_db_handle(&dbh) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB!\n"); return SWITCH_STATUS_FALSE; @@ -1723,7 +1692,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_expire_registration(int force) if (force) { sql = switch_mprintf("delete from registrations where hostname='%q'", switch_core_get_hostname()); } else { - sql = switch_mprintf("delete from registrations where expires <= %ld and hostname='%q'", now, switch_core_get_hostname()); + sql = switch_mprintf("delete from registrations where expires > 0 and expires <= %ld and hostname='%q'", now, switch_core_get_hostname()); } switch_cache_db_execute_sql(dbh, sql, NULL); @@ -1750,8 +1719,6 @@ switch_status_t switch_core_sqldb_start(switch_memory_pool_t *pool, switch_bool_ switch_thread_cond_create(&sql_manager.cond, sql_manager.memory_pool); - switch_core_hash_init(&sql_manager.dbh_hash, sql_manager.memory_pool); - top: if (!sql_manager.manage) goto skip; @@ -1917,7 +1884,7 @@ void switch_core_sqldb_stop(void) if (sql_manager.manage) { switch_queue_push(sql_manager.sql_queue[0], NULL); switch_queue_push(sql_manager.sql_queue[1], NULL); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Waiting for unfinished SQL transactions\n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "Waiting for unfinished SQL transactions\n"); wake_thread(0); } @@ -1933,61 +1900,58 @@ void switch_core_sqldb_stop(void) switch_cache_db_flush_handles(); sql_close(0); - - switch_core_hash_destroy(&sql_manager.dbh_hash); - } SWITCH_DECLARE(void) switch_cache_db_status(switch_stream_handle_t *stream) { /* return some status info suitable for the cli */ - switch_hash_index_t *hi; switch_cache_db_handle_t *dbh = NULL; - void *val; - const void *var; - char *key; switch_bool_t locked = SWITCH_FALSE; time_t now = switch_epoch_time_now(NULL); char cleankey_str[CACHE_DB_LEN]; char *pos1 = NULL; char *pos2 = NULL; + int count = 0, used = 0; switch_mutex_lock(sql_manager.dbh_mutex); - for (hi = switch_hash_first(NULL, sql_manager.dbh_hash); hi; hi = switch_hash_next(hi)) { - switch_hash_this(hi, &var, NULL, &val); - key = (char *) var; + for (dbh = sql_manager.handle_pool; dbh; dbh = dbh->next) { + char *needle = "pass=\""; + time_t diff = 0; - if ((dbh = (switch_cache_db_handle_t *) val)) { - char *needle = "pass=\""; - time_t diff = 0; + diff = now - dbh->last_used; - diff = now - dbh->last_used; - - if (switch_mutex_trylock(dbh->mutex) == SWITCH_STATUS_SUCCESS) { - switch_mutex_unlock(dbh->mutex); - locked = SWITCH_FALSE; - } else { - locked = SWITCH_TRUE; - } - - /* sanitize password */ - memset(cleankey_str, 0, sizeof(cleankey_str)); - pos1 = strstr(key, needle) + strlen(needle); - pos2 = strstr(pos1, "\""); - strncpy(cleankey_str, key, pos1 - key); - strcpy(&cleankey_str[pos1 - key], pos2); - - - stream->write_function(stream, "%s\n\tType: %s\n\tLast used: %d\n\tFlags: %s, %s\n" - "\tCreator: %s\n\tLast User: %s\n", - cleankey_str, - switch_cache_db_type_name(dbh->type), - diff, - locked ? "Locked" : "Unlocked", - switch_test_flag(dbh, CDF_INUSE) ? "Attached" : "Detached", dbh->creator, dbh->last_user); + if (switch_mutex_trylock(dbh->mutex) == SWITCH_STATUS_SUCCESS) { + switch_mutex_unlock(dbh->mutex); + locked = SWITCH_FALSE; + } else { + locked = SWITCH_TRUE; } + + /* sanitize password */ + memset(cleankey_str, 0, sizeof(cleankey_str)); + pos1 = strstr(dbh->name, needle) + strlen(needle); + pos2 = strstr(pos1, "\""); + strncpy(cleankey_str, dbh->name, pos1 - dbh->name); + strcpy(&cleankey_str[pos1 - dbh->name], pos2); + + count++; + + if (switch_test_flag(dbh, CDF_INUSE)) { + used++; + } + + stream->write_function(stream, "%s\n\tType: %s\n\tLast used: %d\n\tFlags: %s, %s\n" + "\tCreator: %s\n\tLast User: %s\n", + cleankey_str, + switch_cache_db_type_name(dbh->type), + diff, + locked ? "Locked" : "Unlocked", + switch_test_flag(dbh, CDF_INUSE) ? "Attached" : "Detached", dbh->creator, dbh->last_user); } + + stream->write_function(stream, "%d total. %d in use.\n", count, used); + switch_mutex_unlock(sql_manager.dbh_mutex); } diff --git a/src/switch_core_state_machine.c b/src/switch_core_state_machine.c index 276acb8585..e2d50704b5 100644 --- a/src/switch_core_state_machine.c +++ b/src/switch_core_state_machine.c @@ -468,7 +468,7 @@ static void api_hook(switch_core_session_t *session, const char *hook_var, int u { if (!zstr(hook_var)) { switch_stream_handle_t stream = { 0 }; - char *cmd = switch_core_session_strdup(session, hook_var); + char *cmd = strdup(hook_var); char *arg = NULL; char *expanded = NULL; @@ -485,7 +485,7 @@ static void api_hook(switch_core_session_t *session, const char *hook_var, int u switch_channel_get_variables(session->channel, &stream.param_event); switch_channel_event_set_data(session->channel, stream.param_event); - expanded = switch_channel_expand_variables(session->channel, arg); + expanded = switch_event_expand_headers(stream.param_event, arg); switch_api_execute(cmd, expanded, use_session ? session : NULL, &stream); @@ -496,6 +496,9 @@ static void api_hook(switch_core_session_t *session, const char *hook_var, int u if (expanded != arg) { switch_safe_free(expanded); } + + switch_safe_free(cmd); + switch_safe_free(stream.data); } } diff --git a/src/switch_cpp.cpp b/src/switch_cpp.cpp index c62946b760..3ffc6a3a9d 100644 --- a/src/switch_cpp.cpp +++ b/src/switch_cpp.cpp @@ -501,8 +501,14 @@ SWITCH_DECLARE_CONSTRUCTOR CoreSession::CoreSession() SWITCH_DECLARE_CONSTRUCTOR CoreSession::CoreSession(char *nuuid, CoreSession *a_leg) { + switch_channel_t *other_channel = NULL; + init_vars(); + if (a_leg && a_leg->session) { + other_channel = switch_core_session_get_channel(a_leg->session); + } + if (!strchr(nuuid, '/') && (session = switch_core_session_locate(nuuid))) { uuid = strdup(nuuid); channel = switch_core_session_get_channel(session); @@ -516,6 +522,7 @@ SWITCH_DECLARE_CONSTRUCTOR CoreSession::CoreSession(char *nuuid, CoreSession *a_ switch_set_flag(this, S_HUP); uuid = strdup(switch_core_session_get_uuid(session)); switch_channel_set_state(switch_core_session_get_channel(session), CS_SOFT_EXECUTE); + switch_channel_wait_for_state(channel, other_channel, CS_SOFT_EXECUTE); } } } diff --git a/src/switch_event.c b/src/switch_event.c index b626d5b846..56ee9e9a9c 100644 --- a/src/switch_event.c +++ b/src/switch_event.c @@ -189,6 +189,8 @@ static char *EVENT_NAMES[] = { "NAT", "RECORD_START", "RECORD_STOP", + "PLAYBACK_START", + "PLAYBACK_STOP", "CALL_UPDATE", "FAILURE", "SOCKET_DATA", diff --git a/src/switch_ivr.c b/src/switch_ivr.c index a40da1b077..5a082763b2 100644 --- a/src/switch_ivr.c +++ b/src/switch_ivr.c @@ -2289,7 +2289,7 @@ SWITCH_DECLARE(void) switch_ivr_delay_echo(switch_core_session_t *session, uint3 qlen = delay_ms / (interval); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Setting delay to %dms (%d frames)\n", delay_ms, qlen); - jb = stfu_n_init(qlen, qlen, read_impl.samples_per_packet, read_impl.samples_per_second); + jb = stfu_n_init(qlen, qlen, read_impl.samples_per_packet, read_impl.samples_per_second, 0); write_frame.codec = switch_core_session_get_read_codec(session); diff --git a/src/switch_ivr_async.c b/src/switch_ivr_async.c index be360138c2..3afbfb6397 100644 --- a/src/switch_ivr_async.c +++ b/src/switch_ivr_async.c @@ -3216,8 +3216,10 @@ static switch_status_t speech_on_dtmf(switch_core_session_t *session, const swit switch_status_t status = SWITCH_STATUS_SUCCESS; switch_asr_flag_t flags = SWITCH_ASR_FLAG_NONE; - if (switch_core_asr_feed_dtmf(sth->ah, dtmf, &flags) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error Feeding DTMF\n"); + if (sth) { + if (switch_core_asr_feed_dtmf(sth->ah, dtmf, &flags) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error Feeding DTMF\n"); + } } return status; @@ -3231,6 +3233,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_stop_detect_speech(switch_core_sessio switch_assert(channel != NULL); if ((sth = switch_channel_get_private(channel, SWITCH_SPEECH_KEY))) { switch_channel_set_private(channel, SWITCH_SPEECH_KEY, NULL); + switch_core_event_hook_remove_recv_dtmf(session, speech_on_dtmf); switch_core_media_bug_remove(session, &sth->bug); return SWITCH_STATUS_SUCCESS; } @@ -3265,14 +3268,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_resume_detect_speech(switch_core_sess SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech_load_grammar(switch_core_session_t *session, char *grammar, char *name) { switch_channel_t *channel = switch_core_session_get_channel(session); - switch_asr_flag_t flags = SWITCH_ASR_FLAG_NONE; struct speech_thread_handle *sth = switch_channel_get_private(channel, SWITCH_SPEECH_KEY); switch_status_t status; if (sth) { if ((status = switch_core_asr_load_grammar(sth->ah, grammar, name)) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Error loading Grammar\n"); - switch_core_asr_close(sth->ah, &flags); + switch_ivr_stop_detect_speech(session); } return status; } @@ -3307,14 +3309,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech_start_input_timers(swit SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech_unload_grammar(switch_core_session_t *session, const char *name) { switch_channel_t *channel = switch_core_session_get_channel(session); - switch_asr_flag_t flags = SWITCH_ASR_FLAG_NONE; struct speech_thread_handle *sth = switch_channel_get_private(channel, SWITCH_SPEECH_KEY); switch_status_t status; if (sth) { if ((status = switch_core_asr_unload_grammar(sth->ah, name)) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Error unloading Grammar\n"); - switch_core_asr_close(sth->ah, &flags); + switch_ivr_stop_detect_speech(session); } return status; } @@ -3324,14 +3325,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech_unload_grammar(switch_c SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech_enable_grammar(switch_core_session_t *session, const char *name) { switch_channel_t *channel = switch_core_session_get_channel(session); - switch_asr_flag_t flags = SWITCH_ASR_FLAG_NONE; struct speech_thread_handle *sth = switch_channel_get_private(channel, SWITCH_SPEECH_KEY); switch_status_t status; if (sth) { if ((status = switch_core_asr_enable_grammar(sth->ah, name)) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Error enabling Grammar\n"); - switch_core_asr_close(sth->ah, &flags); + switch_ivr_stop_detect_speech(session); } return status; } @@ -3341,14 +3341,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech_enable_grammar(switch_c SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech_disable_grammar(switch_core_session_t *session, const char *name) { switch_channel_t *channel = switch_core_session_get_channel(session); - switch_asr_flag_t flags = SWITCH_ASR_FLAG_NONE; struct speech_thread_handle *sth = switch_channel_get_private(channel, SWITCH_SPEECH_KEY); switch_status_t status; if (sth) { if ((status = switch_core_asr_disable_grammar(sth->ah, name)) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Error disabling Grammar\n"); - switch_core_asr_close(sth->ah, &flags); + switch_ivr_stop_detect_speech(session); } return status; } @@ -3358,14 +3357,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech_disable_grammar(switch_ SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech_disable_all_grammars(switch_core_session_t *session) { switch_channel_t *channel = switch_core_session_get_channel(session); - switch_asr_flag_t flags = SWITCH_ASR_FLAG_NONE; struct speech_thread_handle *sth = switch_channel_get_private(channel, SWITCH_SPEECH_KEY); switch_status_t status; if (sth) { if ((status = switch_core_asr_disable_all_grammars(sth->ah)) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Error disabling all Grammars\n"); - switch_core_asr_close(sth->ah, &flags); + switch_ivr_stop_detect_speech(session); } return status; } @@ -3397,7 +3395,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech(switch_core_session_t * if (sth) { if (switch_core_asr_load_grammar(sth->ah, grammar, name) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Error loading Grammar\n"); - switch_core_asr_close(sth->ah, &flags); + switch_ivr_stop_detect_speech(session); return SWITCH_STATUS_FALSE; } diff --git a/src/switch_ivr_bridge.c b/src/switch_ivr_bridge.c index f130625a75..88c72bf1b8 100644 --- a/src/switch_ivr_bridge.c +++ b/src/switch_ivr_bridge.c @@ -1398,10 +1398,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_uuid_bridge(const char *originator_uu return SWITCH_STATUS_FALSE; } - //if (!switch_channel_test_flag(originator_channel, CF_ANSWERED)) { - if (!switch_channel_media_ready(originator_channel)) { - if (switch_channel_media_ready(originatee_channel)) { - //if (switch_channel_test_flag(originatee_channel, CF_ANSWERED)) { + if (!switch_channel_media_up(originator_channel)) { + if (switch_channel_media_up(originatee_channel)) { swap_session = originator_session; originator_session = originatee_session; originatee_session = swap_session; diff --git a/src/switch_ivr_play_say.c b/src/switch_ivr_play_say.c index dc263e9be5..98dfd0f71e 100644 --- a/src/switch_ivr_play_say.c +++ b/src/switch_ivr_play_say.c @@ -746,12 +746,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se } - if (switch_event_create(&event, SWITCH_EVENT_RECORD_STOP) == SWITCH_STATUS_SUCCESS) { - switch_channel_event_set_data(channel, event); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Record-File-Path", file); - switch_event_fire(&event); - } - if (fill_cng || waste_resources) { switch_core_codec_destroy(&write_codec); } @@ -766,6 +760,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se switch_channel_set_variable_printf(channel, "record_samples", "%d", fh->samples_out); + if (switch_event_create(&event, SWITCH_EVENT_RECORD_STOP) == SWITCH_STATUS_SUCCESS) { + switch_channel_event_set_data(channel, event); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Record-File-Path", file); + switch_event_fire(&event); + } + switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE); return status; } @@ -951,6 +951,38 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_release_file_handle(switch_core_sessi #define FILE_BLOCKSIZE 1024 * 8 #define FILE_BUFSIZE 1024 * 64 +static void add_playback_vars_to_event(switch_core_session_t *session, switch_event_t *event, char *vars) +{ + char *tmp; + + if (!session || !event || !vars) + return; + + if ((tmp = switch_core_session_strdup(session, vars))) { + char *argv[128] = { 0 }; + int argc, i; + + if (!(argc = switch_separate_string(tmp, ',', argv, (sizeof(argv) / sizeof(argv[0]))))) + return; + + for (i = 0; i < argc; i++) { + char *var, *val; + + if ((var = strchr(argv[i], '='))) { + *var = '\0'; + val = var+1; + var = argv[i]; + + if (var && *var && val && *val) { + if ((var = switch_core_session_sprintf(session, "playback_variable_%s", var))) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, var, val); + } + } + } + } + } +} + SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *session, switch_file_handle_t *fh, const char *file, switch_input_args_t *args) { switch_channel_t *channel = switch_core_session_get_channel(session); @@ -990,6 +1022,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess int timeout_samples = 0; const char *var; int more_data = 0; + char *playback_vars, *tmp; + switch_event_t *event; if (switch_channel_pre_answer(channel) != SWITCH_STATUS_SUCCESS) { return SWITCH_STATUS_FALSE; @@ -1138,6 +1172,19 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess } } + /* Try to parse extra parameters for this playback (parameters within {} at the end of the filename */ + playback_vars = NULL; + if ((tmp = strchr(file, '{'))) { + char *tfile, *e; + + if ((tfile = switch_core_session_strdup(session, tmp))) { + if ((e = switch_find_end_paren(tfile, '{', '}')) && *(e + 1) == '\0') { + *tmp = '\0'; + *e = '\0'; + playback_vars = tfile+1; + } + } + } if (!fh) { fh = &lfh; @@ -1293,6 +1340,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess ilen = samples; + if (switch_event_create(&event, SWITCH_EVENT_PLAYBACK_START) == SWITCH_STATUS_SUCCESS) { + switch_channel_event_set_data(channel, event); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Playback-File-Path", file); + add_playback_vars_to_event(session, event, playback_vars); + switch_event_fire(&event); + } + for (;;) { int do_speed = 1; int last_speed = -1; @@ -1586,6 +1640,18 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess } switch_channel_set_variable_printf(channel, "playback_samples", "%d", fh->samples_in); + if (switch_event_create(&event, SWITCH_EVENT_PLAYBACK_STOP) == SWITCH_STATUS_SUCCESS) { + switch_channel_event_set_data(channel, event); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Playback-File-Path", file); + if (status == SWITCH_STATUS_BREAK) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Playback-Status", "break"); + } else { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Playback-Status", "done"); + } + add_playback_vars_to_event(session, event, playback_vars); + switch_event_fire(&event); + } + switch_core_session_io_write_lock(session); switch_channel_set_private(channel, "__fh", NULL); switch_core_session_io_rwunlock(session); diff --git a/src/switch_nat.c b/src/switch_nat.c index 85b0247d6d..d9110efe18 100644 --- a/src/switch_nat.c +++ b/src/switch_nat.c @@ -325,9 +325,9 @@ static void *SWITCH_THREAD_FUNC switch_nat_multicast_runtime(switch_thread_t * t do_repub = SWITCH_TRUE; switch_event_create(&event, SWITCH_EVENT_TRAP); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "condition", "network-address-change"); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "network-address-previous-v4", nat_globals.pub_addr); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "network-address-change-v4", newip); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "condition", "network-external-address-change"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "network-external-address-previous-v4", nat_globals.pub_addr); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "network-external-address-change-v4", newip); switch_event_fire(&event); switch_set_string(nat_globals.pub_addr, newip); diff --git a/src/switch_resample.c b/src/switch_resample.c index 10c633c01a..9c7f9b95d2 100644 --- a/src/switch_resample.c +++ b/src/switch_resample.c @@ -269,25 +269,29 @@ SWITCH_DECLARE(void) switch_mux_channels(int16_t *data, switch_size_t samples, u } -SWITCH_DECLARE(void) switch_change_sln_volume(int16_t *data, uint32_t samples, int32_t vol) +SWITCH_DECLARE(void) switch_change_sln_volume_granular(int16_t *data, uint32_t samples, int32_t vol) { double newrate = 0; - int div = 0; + double pos[12] = {1.25, 1.50, 1.75, 2.0, 2.25, 2.50, 2.75, 3.0, 3.25, 3.50, 3.75, 4.0}; + double neg[12] = {.917, .834, .751, .668, .585, .502, .419, .336, .253, .017, .087, .004}; + double *chart; + uint32_t i; - switch_normalize_volume(vol); + if (vol == 0) return; + + switch_normalize_volume_granular(vol); if (vol > 0) { - vol++; - } else if (vol < 0) { - vol--; + chart = pos; + } else { + chart = neg; } + + i = abs(vol) - 1; + + switch_assert(i < 12); - newrate = vol * 1.3; - - if (vol < 0) { - newrate *= -1; - div++; - } + newrate = chart[i]; if (newrate) { int32_t tmp; @@ -295,7 +299,44 @@ SWITCH_DECLARE(void) switch_change_sln_volume(int16_t *data, uint32_t samples, i int16_t *fp = data; for (x = 0; x < samples; x++) { - tmp = (int32_t) (div ? fp[x] / newrate : fp[x] * newrate); + tmp = (int32_t) (fp[x] * newrate); + switch_normalize_to_16bit(tmp); + fp[x] = (int16_t) tmp; + } + } +} + +SWITCH_DECLARE(void) switch_change_sln_volume(int16_t *data, uint32_t samples, int32_t vol) +{ + double newrate = 0; + double pos[4] = {1.3, 2.3, 3.3, 4.3}; + double neg[4] = {.80, .60, .40, .20}; + double *chart; + uint32_t i; + + if (vol == 0) return; + + switch_normalize_volume(vol); + + if (vol > 0) { + chart = pos; + } else { + chart = neg; + } + + i = abs(vol) - 1; + + switch_assert(i < 4); + + newrate = chart[i]; + + if (newrate) { + int32_t tmp; + uint32_t x; + int16_t *fp = data; + + for (x = 0; x < samples; x++) { + tmp = (int32_t) (fp[x] * newrate); switch_normalize_to_16bit(tmp); fp[x] = (int16_t) tmp; } diff --git a/src/switch_rtp.c b/src/switch_rtp.c index d0c22ce585..f5a7022928 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -235,7 +235,6 @@ struct switch_rtp { uint32_t sync_packets; int rtcp_interval; switch_bool_t rtcp_fresh_frame; - uint8_t checked_jb; #ifdef ENABLE_ZRTP zrtp_session_t *zrtp_session; zrtp_profile_t *zrtp_profile; @@ -1830,7 +1829,7 @@ static void jb_callback(stfu_instance_t *i, void *udata) stfu_n_report(i, &r); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG1, + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG8, "%s JB REPORT:\nlen: %u\nin: %u\nclean: %u\ngood: %u\nbad: %u\n", switch_core_session_get_name(session), r.qlen, @@ -1910,7 +1909,8 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_activate_jitter_buffer(switch_rtp_t * uint32_t queue_frames, uint32_t max_queue_frames, uint32_t samples_per_packet, - uint32_t samples_per_second) + uint32_t samples_per_second, + uint32_t max_drift) { if (!switch_rtp_ready(rtp_session)) { @@ -1921,7 +1921,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_activate_jitter_buffer(switch_rtp_t * if (rtp_session->jb) { stfu_n_resize(rtp_session->jb, queue_frames); } else { - rtp_session->jb = stfu_n_init(queue_frames, max_queue_frames ? max_queue_frames : 50, samples_per_packet, samples_per_second); + rtp_session->jb = stfu_n_init(queue_frames, max_queue_frames ? max_queue_frames : 50, samples_per_packet, samples_per_second, max_drift); } READ_DEC(rtp_session); @@ -2304,7 +2304,8 @@ static void do_2833(switch_rtp_t *rtp_session, switch_core_session_t *session) SWITCH_DECLARE(void) rtp_flush_read_buffer(switch_rtp_t *rtp_session, switch_rtp_flush_t flush) { - if (switch_rtp_ready(rtp_session) && !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA)) { + if (switch_rtp_ready(rtp_session) && !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA) && + !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_VIDEO)) { switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_FLUSH); switch (flush) { case SWITCH_RTP_FLUSH_STICK: @@ -2396,14 +2397,14 @@ static void do_flush(switch_rtp_t *rtp_session) #define return_cng_frame() do_cng = 1; goto timer_check -static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t *bytes, switch_frame_flag_t *flags) +static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t *bytes, switch_frame_flag_t *flags, switch_bool_t return_jb_packet) { switch_status_t status = SWITCH_STATUS_FALSE; stfu_frame_t *jb_frame; uint32_t ts; switch_assert(bytes); - + more: *bytes = sizeof(rtp_msg_t); status = switch_socket_recvfrom(rtp_session->from_addr, rtp_session->sock_input, 0, (void *) &rtp_session->recv_msg, bytes); ts = ntohl(rtp_session->recv_msg.header.ts); @@ -2490,14 +2491,21 @@ static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t stfu_n_reset(rtp_session->jb); } - stfu_n_eat(rtp_session->jb, rtp_session->last_read_ts, - rtp_session->recv_msg.header.pt, - rtp_session->recv_msg.body, *bytes - rtp_header_len, rtp_session->timer.samplecount); - *bytes = 0; + if (stfu_n_eat(rtp_session->jb, rtp_session->last_read_ts, + rtp_session->recv_msg.header.pt, + rtp_session->recv_msg.body, *bytes - rtp_header_len, rtp_session->timer.samplecount) == STFU_ITS_TOO_LATE) { + printf("doh\n"); + goto more; + } + status = SWITCH_STATUS_FALSE; + if (!return_jb_packet) { + return status; + } + *bytes = 0; } - if (rtp_session->jb && !rtp_session->pause_jb && !rtp_session->checked_jb) { + if (rtp_session->jb && !rtp_session->pause_jb) { if ((jb_frame = stfu_n_read_a_frame(rtp_session->jb))) { memcpy(rtp_session->recv_msg.body, jb_frame->data, jb_frame->dlen); @@ -2511,8 +2519,6 @@ static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t rtp_session->recv_msg.header.pt = jb_frame->pt; status = SWITCH_STATUS_SUCCESS; } - - rtp_session->checked_jb++; } return status; @@ -2657,8 +2663,6 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_ READ_INC(rtp_session); - rtp_session->checked_jb = 0; - while (switch_rtp_ready(rtp_session)) { int do_cng = 0; int read_pretriggered = 0; @@ -2668,17 +2672,19 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_ if ((switch_test_flag(rtp_session, SWITCH_RTP_FLAG_AUTOFLUSH) || switch_test_flag(rtp_session, SWITCH_RTP_FLAG_STICKY_FLUSH)) && rtp_session->read_pollfd) { if (switch_poll(rtp_session->read_pollfd, 1, &fdr, 0) == SWITCH_STATUS_SUCCESS) { - status = read_rtp_packet(rtp_session, &bytes, flags); - /* switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Initial %d\n", bytes); */ - read_pretriggered = 1; + status = read_rtp_packet(rtp_session, &bytes, flags, SWITCH_FALSE); + /* switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Initial (%i) %d\n", status, bytes); */ + if (status != SWITCH_STATUS_FALSE) { + read_pretriggered = 1; + } - if (switch_poll(rtp_session->read_pollfd, 1, &fdr, 0) == SWITCH_STATUS_SUCCESS) { - /* switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Trigger %d\n", rtp_session->hot_hits); */ - rtp_session->hot_hits += rtp_session->samples_per_interval; - } else { - rtp_session->hot_hits = 0; - switch_core_timer_sync(&rtp_session->timer); - goto recvfrom; + if (bytes) { + if (switch_poll(rtp_session->read_pollfd, 1, &fdr, 0) == SWITCH_STATUS_SUCCESS) { + /* switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Trigger %d\n", rtp_session->hot_hits); */ + rtp_session->hot_hits += rtp_session->samples_per_interval; + } else { + rtp_session->hot_hits = 0; + } } if (rtp_session->hot_hits >= rtp_session->samples_per_second * 5) { @@ -2737,9 +2743,11 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_ } if (poll_status == SWITCH_STATUS_SUCCESS) { - if (!read_pretriggered) { - status = read_rtp_packet(rtp_session, &bytes, flags); - /* switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Read bytes %d\n", bytes); */ + if (read_pretriggered) { + read_pretriggered = 0; + } else { + status = read_rtp_packet(rtp_session, &bytes, flags, SWITCH_TRUE); + /* switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Read bytes (%i) %d\n", status, bytes); */ } } else { if (!SWITCH_STATUS_IS_BREAK(poll_status) && poll_status != SWITCH_STATUS_TIMEOUT) { @@ -2848,6 +2856,7 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_ goto end; } + if (bytes && rtp_session->recv_msg.header.version == 2 && !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA) && !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_UDPTL) && rtp_session->recv_msg.header.pt != 13 && @@ -2883,10 +2892,12 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_ } if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_FLUSH)) { + if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_VIDEO)) { do_flush(rtp_session); - switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_FLUSH); bytes = 0; } + switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_FLUSH); + } if (bytes && bytes < 5) { continue;