Index: build_tools/cflags.xml =================================================================== --- build_tools/cflags.xml (revision 87121) +++ build_tools/cflags.xml (working copy) @@ -32,3 +32,24 @@ yes + + + yes + BUSYDETECT + + + BUSYDETECT_MARTIN + no + + + BUSYDETECT_COMPARE_TONE_AND_SILENCE + no + + + BUSYDETECT_TONEONLY + no + + + no + + Index: build_tools/make_buildopts_h =================================================================== --- build_tools/make_buildopts_h (revision 87121) +++ build_tools/make_buildopts_h (working copy) @@ -7,7 +7,7 @@ */ END -TMP=`${GREP} MENUSELECT_CFLAGS menuselect.makeopts | sed 's/MENUSELECT_CFLAGS\=//g' | sed 's/-D//g'` +TMP=`${GREP} '^MENUSELECT_.*CFLAGS=' menuselect.makeopts | sed 's/^MENUSELECT_.*CFLAGS\=//g' | sed 's/-D//g'` for x in ${TMP}; do echo "#define ${x} 1" done Index: channels/chan_zap.c =================================================================== --- channels/chan_zap.c (revision 87121) +++ channels/chan_zap.c (working copy) @@ -9926,6 +9926,29 @@ ast_cli(fd, "Propagated Conference: %d\n", tmp->propconfno); ast_cli(fd, "Real in conference: %d\n", tmp->inconference); ast_cli(fd, "DSP: %s\n", tmp->dsp ? "yes" : "no"); + ast_cli(fd, "Busy Detection %s\n", tmp->busydetect ? "yes" : "no" ); + if (tmp->busydetect) { + ast_cli(fd, "\tBusy Detector: "); +#ifdef BUSYDETECT + ast_cli(fd, "BUSYDETECT "); +#endif +#ifdef BUSYDETECT_MARTIN + ast_cli(fd, "BUSYDETECT_MARTING "); +#endif +#ifdef BUSYDETECT_TONEONLY + ast_cli(fd, "BUSYDETECT_TONEONLY "); +#endif +#ifdef BUSYDETECT_COMPARE_TONE_AND_SILECE + ast_cli(fd, "BUSYDETECT_COMPARE_TONE_AND_SILECE "); +#endif +#ifdef BUSYDETECT_DEBUG + ast_cli(fd, "BUSYDETECT_DEBUG "); +#endif + ast_cli(fd, "\n"); + ast_cli(fd, "\tBusy Count: %d\n", tmp->busycount); + ast_cli(fd, "\tBusy Pattern: %d,%d\n", tmp->busy_tonelength, tmp->busy_quietlength); + } + ast_cli(fd, "Relax DTMF: %s\n", tmp->dtmfrelax ? "yes" : "no"); ast_cli(fd, "Dialing/CallwaitCAS: %d/%d\n", tmp->dialing, tmp->callwaitcas); ast_cli(fd, "Default law: %s\n", tmp->law == ZT_LAW_MULAW ? "ulaw" : tmp->law == ZT_LAW_ALAW ? "alaw" : "unknown"); Index: main/dsp.c =================================================================== --- main/dsp.c (revision 87295) +++ main/dsp.c (working copy) @@ -59,7 +59,9 @@ #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 { GSAMP_SIZE_NA = 183, /*!< North America - 350, 440, 480, 620, 950, 1400, 1800 Hz */ @@ -186,9 +188,15 @@ #define BELL_MF_RELATIVE_PEAK 12.6 /* 11dB */ #endif -#if !defined(BUSYDETECT_MARTIN) && !defined(BUSYDETECT) && !defined(BUSYDETECT_TONEONLY) && !defined(BUSYDETECT_COMPARE_TONE_AND_SILENCE) +#ifndef BUSYDETECT_MARTIN +#ifndef BUSYDETECT #define BUSYDETECT_MARTIN +#warning You didn't selected BUSYDETECT_MARTIN or BUSYDETECT option via make menuselect #endif +#endif +#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 { float v2; @@ -1335,9 +1343,11 @@ /* 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", +#ifdef BUSYDETECT_DEBUG + if (option_debug>200) { + ast_log(LOG_WARNING, "busy detector: avgtone of %d not close enough to desired %d\n", avgtone, dsp->busy_tonelength); + } #endif res = 0; } @@ -1346,18 +1356,29 @@ /* 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", +#ifdef BUSYDETECT_DEBUG + if (option_debug>200) { + ast_log(LOG_WARNING, "busy detector: avgsilence of %d not close enough to desired %d\n", avgsilence, dsp->busy_quietlength); + } #endif res = 0; } } #endif #ifndef BUSYDETECT_TONEONLY -#if 1 - if (res) - ast_log(LOG_DEBUG, "ast_dsp_busydetect detected busy, avgtone: %d, avgsilence %d\n", avgtone, avgsilence); +#ifdef BUSYDETECT_DEBUG + if (option_debug>200) { + if (res) { + ast_log(LOG_WARNING, "ast_dsp_busydetect detected busy, avgtone: %d, avgsilence %d\n", avgtone, avgsilence); + } else { + ast_log(LOG_WARNING, "busy detector: FAILED with avgtone: %d, avgsilence %d\n", avgtone, avgsilence); + } + } else { + if (res) { + ast_log(LOG_DEBUG, "ast_dsp_busydetect detected busy, avgtone: %d, avgsilence %d\n", avgtone, avgsilence); + } + } #endif #endif return res; Index: configs/zapata.conf.sample =================================================================== --- configs/zapata.conf.sample (revision 87121) +++ configs/zapata.conf.sample (working copy) @@ -460,6 +460,10 @@ ; silence (as many countries do), consider defining the ; -DBUSYDETECT_COMPARE_TONE_AND_SILENCE option. ; +; To further detect wich hangup tone is your telco provider sending is usefull +; to use the ztmonitor utility to record the audio main/dsp.c is receiving +; after the caller hangup +; ; Use a polarity reversal to mark when a outgoing call is answered by the ; remote party. ;