diff --git a/Makefile b/Makefile index 5127e3fd0bdaed1594c767b357b77fc81c26f196..5b8951809aba6ccf97eb15cbd2203b1cf50ad21b 100644 --- a/Makefile +++ b/Makefile @@ -275,9 +275,7 @@ endif # XXX MALLOC_DEBUG is probably unused, Makefile.moddir_rules adds the # value directly to ASTCFLAGS -# XXX BUSYDETECT is probably useless, the only similar reference is to -# #ifdef BUSYDETECT in main/dsp.c -ASTCFLAGS+=$(MALLOC_DEBUG)$(BUSYDETECT)$(OPTIONS) +ASTCFLAGS+=$(MALLOC_DEBUG)$(OPTIONS) MOD_SUBDIRS:=channels pbx apps codecs formats cdr funcs tests main res $(LOCAL_MOD_SUBDIRS) OTHER_SUBDIRS:=utils agi diff --git a/build_tools/cflags.xml b/build_tools/cflags.xml index 87b21e5193c4ba2e021df9583525bd8e186ecdc2..fa69c1263611b5d4e7b88656305ff1da203307af 100644 --- a/build_tools/cflags.xml +++ b/build_tools/cflags.xml @@ -48,4 +48,15 @@ </member> <member name="THREAD_CRASH" displayname="Crash on mutex errors"> </member> + <member name="BUSYDETECT_TONEONLY" displayname="Enable additional comparision of only the tone duration not the silence part"> + <conflict>BUSYDETECT_COMPARE_TONE_AND_SILENCE</conflict> + <defaultenabled>no</defaultenabled> + </member> + <member name="BUSYDETECT_COMPARE_TONE_AND_SILENCE" displayname="Assume that tone and silence have the same duration"> + <conflict>BUSYDETECT_TONEONLY</conflict> + <defaultenabled>no</defaultenabled> + </member> + <member name="BUSYDETECT_DEBUG" displayname="Enable additional busy detection debugging"> + <defaultenabled>no</defaultenabled> + </member> </category> diff --git a/channels/chan_zap.c b/channels/chan_zap.c index bb7f038d82d66ef07e1b572a0035e229b2800863..08dc2aead2275dd1b056f58260f900409c60feb1 100644 --- a/channels/chan_zap.c +++ b/channels/chan_zap.c @@ -11829,6 +11829,19 @@ static char *zap_show_channel(struct ast_cli_entry *e, int cmd, struct ast_cli_a ast_cli(a->fd, "Propagated Conference: %d\n", tmp->propconfno); ast_cli(a->fd, "Real in conference: %d\n", tmp->inconference); ast_cli(a->fd, "DSP: %s\n", tmp->dsp ? "yes" : "no"); + ast_cli(a->fd, "Busy Detection: %s\n", tmp->busydetect ? "yes" : "no"); + if (tmp->busydetect) { +#if defined(BUSYDETECT_TONEONLY) + ast_cli(a->fd, " Busy Detector Helper: BUSYDETECT_TONEONLY\n"); +#elif defined(BUSYDETECT_COMPARE_TONE_AND_SILENCE) + ast_cli(a->fd, " Busy Detector Helper: BUSYDETECT_COMPARE_TONE_AND_SILENCE\n"); +#endif +#ifdef BUSYDETECT_DEBUG + ast_cli(a->fd, " Busy Detector Debug: Enabled\n"); +#endif + ast_cli(a->fd, " Busy Count: %d\n", tmp->busycount); + ast_cli(a->fd, " Busy Pattern: %d,%d\n", tmp->busy_tonelength, tmp->busy_quietlength); + } ast_cli(a->fd, "TDD: %s\n", tmp->tdd ? "yes" : "no"); ast_cli(a->fd, "Relax DTMF: %s\n", tmp->dtmfrelax ? "yes" : "no"); ast_cli(a->fd, "Dialing/CallwaitCAS: %d/%d\n", tmp->dialing, tmp->callwaitcas); diff --git a/configs/zapata.conf.sample b/configs/zapata.conf.sample index e825576b29cdc0c7fc4f275afb7023f1ee95fb5f..b2146b6b5eae73d81237e422decbc0d1cf181ede 100644 --- a/configs/zapata.conf.sample +++ b/configs/zapata.conf.sample @@ -599,10 +599,14 @@ pickupgroup=1 ; ;busypattern=500,500 ; -; NOTE: In the Asterisk Makefile you'll find further options to tweak the busy +; NOTE: In make menuselect, you'll find further options to tweak the busy ; detector. If your country has a busy tone with the same length tone and -; silence (as many countries do), consider defining the -; -DBUSYDETECT_COMPARE_TONE_AND_SILENCE option. +; silence (as many countries do), consider enabling the +; BUSYDETECT_COMPARE_TONE_AND_SILENCE option. +; +; To further detect which hangup tone your telco provider is sending, it is +; useful to use the ztmonitor utility to record the audio that main/dsp.c +; is receiving after the caller hangs up. ; ; Use a polarity reversal to mark when a outgoing call is answered by the ; remote party. diff --git a/main/dsp.c b/main/dsp.c index 9d268d69ff63b578a006ea738c2dd25cedce0c6b..8355aca4ec07a1d3459dc99f09b5782f3a57c620 100644 --- a/main/dsp.c +++ b/main/dsp.c @@ -52,6 +52,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/ulaw.h" #include "asterisk/alaw.h" #include "asterisk/utils.h" +#include "asterisk/options.h" /*! Number of goertzels for progress detect */ enum gsamp_size { @@ -162,8 +163,8 @@ enum gsamp_thresh { #define BELL_MF_TWIST 4.0 /* 6dB */ #define BELL_MF_RELATIVE_PEAK 12.6 /* 11dB */ -#if !defined(BUSYDETECT_MARTIN) && !defined(BUSYDETECT) && !defined(BUSYDETECT_TONEONLY) && !defined(BUSYDETECT_COMPARE_TONE_AND_SILENCE) -#define BUSYDETECT_MARTIN +#if defined(BUSYDETECT_TONEONLY) && defined(BUSYDETECT_COMPARE_TONE_AND_SILENCE) +#error You cant use BUSYDETECT_TONEONLY together with BUSYDETECT_COMPARE_TONE_AND_SILENCE #endif typedef struct { @@ -902,7 +903,6 @@ static int __ast_dsp_silence(struct ast_dsp *dsp, short *s, int len, int *totals return res; } -#ifdef BUSYDETECT_MARTIN int ast_dsp_busydetect(struct ast_dsp *dsp) { int res = 0, x; @@ -948,9 +948,6 @@ int ast_dsp_busydetect(struct ast_dsp *dsp) if ((hittone >= dsp->busycount - 1) && (avgtone >= BUSY_MIN && avgtone <= BUSY_MAX)) { #endif #ifdef BUSYDETECT_COMPARE_TONE_AND_SILENCE -#ifdef BUSYDETECT_TONEONLY -#error You cant use BUSYDETECT_TONEONLY together with BUSYDETECT_COMPARE_TONE_AND_SILENCE -#endif if (avgtone > avgsilence) { if (avgtone - avgtone*BUSY_PERCENT/100 <= avgsilence) res = 1; @@ -965,9 +962,9 @@ int ast_dsp_busydetect(struct ast_dsp *dsp) /* If we know the expected busy tone length, check we are in the range */ if (res && (dsp->busy_tonelength > 0)) { if (abs(avgtone - dsp->busy_tonelength) > (dsp->busy_tonelength*BUSY_PAT_PERCENT/100)) { -#if 0 - ast_log(LOG_NOTICE, "busy detector: avgtone of %d not close enough to desired %d\n", - avgtone, dsp->busy_tonelength); +#ifdef BUSYDETECT_DEBUG + ast_debug(5, "busy detector: avgtone of %d not close enough to desired %d\n", + avgtone, dsp->busy_tonelength); #endif res = 0; } @@ -976,67 +973,23 @@ int ast_dsp_busydetect(struct ast_dsp *dsp) /* If we know the expected busy tone silent-period length, check we are in the range */ if (res && (dsp->busy_quietlength > 0)) { if (abs(avgsilence - dsp->busy_quietlength) > (dsp->busy_quietlength*BUSY_PAT_PERCENT/100)) { -#if 0 - ast_log(LOG_NOTICE, "busy detector: avgsilence of %d not close enough to desired %d\n", - avgsilence, dsp->busy_quietlength); +#ifdef BUSYDETECT_DEBUG + ast_debug(5, "busy detector: avgsilence of %d not close enough to desired %d\n", + avgsilence, dsp->busy_quietlength); #endif res = 0; } } #endif -#ifndef BUSYDETECT_TONEONLY +#if !defined(BUSYDETECT_TONEONLY) && defined(BUSYDETECT_DEBUG) if (res) { - ast_debug(1, "ast_dsp_busydetect detected busy, avgtone: %d, avgsilence %d\n", avgtone, avgsilence); + ast_debug(5, "ast_dsp_busydetect detected busy, avgtone: %d, avgsilence %d\n", avgtone, avgsilence); + } else { + ast_debug(5, "busy detector: FAILED with avgtone: %d, avgsilence %d\n", avgtone, avgsilence); } #endif return res; } -#endif - -#ifdef BUSYDETECT -int ast_dsp_busydetect(struct ast_dsp *dsp) -{ - int x; - int res = 0; - int max, min; - -#if 0 - if (dsp->busy_hits > 5); - return 0; -#endif - if (dsp->busymaybe) { -#if 0 - printf("Maybe busy!\n"); -#endif - dsp->busymaybe = 0; - min = 9999; - max = 0; - for (x = DSP_HISTORY - dsp->busycount; x < DSP_HISTORY; x++) { -#if 0 - printf("Silence: %d, Noise: %d\n", dsp->historicsilence[x], dsp->historicnoise[x]); -#endif - if (dsp->historicsilence[x] < min) - min = dsp->historicsilence[x]; - if (dsp->historicnoise[x] < min) - min = dsp->historicnoise[x]; - if (dsp->historicsilence[x] > max) - max = dsp->historicsilence[x]; - if (dsp->historicnoise[x] > max) - max = dsp->historicnoise[x]; - } - if ((max - min < BUSY_THRESHOLD) && (max < BUSY_MAX) && (min > BUSY_MIN)) { -#if 0 - printf("Busy!\n"); -#endif - res = 1; - } -#if 0 - printf("Min: %d, max: %d\n", min, max); -#endif - } - return res; -} -#endif int ast_dsp_silence(struct ast_dsp *dsp, struct ast_frame *f, int *totalsilence) {