Make faxdetect configurable and turn OFF by default
authorMark Spencer <markster@digium.com>
Mon, 7 Jun 2004 23:38:39 +0000 (23:38 +0000)
committerMark Spencer <markster@digium.com>
Mon, 7 Jun 2004 23:38:39 +0000 (23:38 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@3170 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_zap.c
dsp.c
include/asterisk/dsp.h

index 9cc2cb4..835f37e 100755 (executable)
@@ -4197,9 +4197,12 @@ static struct ast_channel *zt_new(struct zt_pvt *i, int state, int startpbx, int
                if (i->busydetect && CANBUSYDETECT(i)) {
                        features |= DSP_FEATURE_BUSY_DETECT;
                }
                if (i->busydetect && CANBUSYDETECT(i)) {
                        features |= DSP_FEATURE_BUSY_DETECT;
                }
-               if (i->callprogress && CANPROGRESSDETECT(i)) {
+               if ((i->callprogress & 1) && CANPROGRESSDETECT(i)) {
                        features |= DSP_FEATURE_CALL_PROGRESS;
                }
                        features |= DSP_FEATURE_CALL_PROGRESS;
                }
+               if (i->callprogress & 2) {
+                       features |= DSP_FEATURE_FAX_DETECT;
+               }
                features |= DSP_FEATURE_DTMF_DETECT;
                if (features) {
                        if (i->dsp) {
                features |= DSP_FEATURE_DTMF_DETECT;
                if (features) {
                        if (i->dsp) {
@@ -6589,7 +6592,6 @@ static void *pri_dchannel(void *vpri)
        struct zt_pri *pri = vpri;
        pri_event *e;
        struct pollfd fds[NUM_DCHANS];
        struct zt_pri *pri = vpri;
        pri_event *e;
        struct pollfd fds[NUM_DCHANS];
-       struct zt_spaninfo si;
        int res;
        int chanpos = 0;
        int x;
        int res;
        int chanpos = 0;
        int x;
@@ -8406,7 +8408,15 @@ static int setup_zap(void)
                } else if (!strcasecmp(v->name, "busycount")) {
                        busycount = atoi(v->value);
                } else if (!strcasecmp(v->name, "callprogress")) {
                } else if (!strcasecmp(v->name, "busycount")) {
                        busycount = atoi(v->value);
                } else if (!strcasecmp(v->name, "callprogress")) {
-                       callprogress = ast_true(v->value);
+                       if (ast_true(v->value))
+                               callprogress |= 1;
+                       else
+                               callprogress &= ~1;
+               } else if (!strcasecmp(v->name, "faxdetect")) {
+                       if (ast_true(v->value))
+                               callprogress |= 2;
+                       else
+                               callprogress &= ~2;
                } else if (!strcasecmp(v->name, "echocancel")) {
                        if (v->value && !ast_strlen_zero(v->value)) {
                                y = atoi(v->value);
                } else if (!strcasecmp(v->name, "echocancel")) {
                        if (v->value && !ast_strlen_zero(v->value)) {
                                y = atoi(v->value);
diff --git a/dsp.c b/dsp.c
index fa66318..2f2662e 100755 (executable)
--- a/dsp.c
+++ b/dsp.c
@@ -390,7 +390,7 @@ static void ast_mf_detect_init (mf_detect_state_t *s)
 static int dtmf_detect (dtmf_detect_state_t *s,
                  int16_t amp[],
                  int samples, 
 static int dtmf_detect (dtmf_detect_state_t *s,
                  int16_t amp[],
                  int samples, 
-                int digitmode, int *writeback)
+                int digitmode, int *writeback, int faxdetect)
 {
 
     float row_energy[4];
 {
 
     float row_energy[4];
@@ -639,21 +639,7 @@ static int dtmf_detect (dtmf_detect_state_t *s,
             }
         } 
 #ifdef FAX_DETECT
             }
         } 
 #ifdef FAX_DETECT
-#ifdef OLD_DSP_ROUTINES
-               if (!hit && (fax_energy >= FAX_THRESHOLD) && (fax_energy > s->energy * 21.0)) {
-                               fax_energy_2nd = goertzel_result(&s->fax_tone2nd);
-                               fax_energy_2nd = goertzel_result(&s->fax_tone2nd);
-                               if (fax_energy_2nd * FAX_2ND_HARMONIC < fax_energy) {
-#if 0
-                                       printf("Fax energy/Second Harmonic: %f/%f\n", fax_energy, fax_energy_2nd);
-#endif                                 
-                                       /* XXX Probably need better checking than just this the energy XXX */
-                                       hit = 'f';
-                                       s->fax_hits++;
-                               } /* Don't reset fax hits counter */
-               }
-#else /* OLD_DSP_ROUTINES */
-               if (!hit && (fax_energy >= FAX_THRESHOLD) && (fax_energy >= DTMF_TO_TOTAL_ENERGY*s->energy)) {
+               if (!hit && (fax_energy >= FAX_THRESHOLD) && (fax_energy >= DTMF_TO_TOTAL_ENERGY*s->energy) && (faxdetect)) {
 #if 0
                                printf("Fax energy/Second Harmonic: %f\n", fax_energy);
 #endif                                 
 #if 0
                                printf("Fax energy/Second Harmonic: %f\n", fax_energy);
 #endif                                 
@@ -661,7 +647,6 @@ static int dtmf_detect (dtmf_detect_state_t *s,
                                hit = 'f';
                                s->fax_hits++;
                }
                                hit = 'f';
                                s->fax_hits++;
                }
-#endif /* OLD_DSP_ROUTINES */
                else {
                        if (s->fax_hits > 5) {
                                 hit = 'f';
                else {
                        if (s->fax_hits > 5) {
                                 hit = 'f';
@@ -1057,7 +1042,7 @@ static int __ast_dsp_digitdetect(struct ast_dsp *dsp, short *s, int len, int *wr
        if (dsp->digitmode & DSP_DIGITMODE_MF)
                res = mf_detect(&dsp->td.mf, s, len, dsp->digitmode & DSP_DIGITMODE_RELAXDTMF, writeback);
        else
        if (dsp->digitmode & DSP_DIGITMODE_MF)
                res = mf_detect(&dsp->td.mf, s, len, dsp->digitmode & DSP_DIGITMODE_RELAXDTMF, writeback);
        else
-               res = dtmf_detect(&dsp->td.dtmf, s, len, dsp->digitmode & DSP_DIGITMODE_RELAXDTMF, writeback);
+               res = dtmf_detect(&dsp->td.dtmf, s, len, dsp->digitmode & DSP_DIGITMODE_RELAXDTMF, writeback, dsp->features & DSP_FEATURE_FAX_DETECT);
        return res;
 }
 
        return res;
 }
 
index 2f28c5d..916e248 100755 (executable)
@@ -18,6 +18,7 @@
 #define DSP_FEATURE_BUSY_DETECT      (1 << 1)
 #define DSP_FEATURE_CALL_PROGRESS    (1 << 2)
 #define DSP_FEATURE_DTMF_DETECT                 (1 << 3)
 #define DSP_FEATURE_BUSY_DETECT      (1 << 1)
 #define DSP_FEATURE_CALL_PROGRESS    (1 << 2)
 #define DSP_FEATURE_DTMF_DETECT                 (1 << 3)
+#define DSP_FEATURE_FAX_DETECT          (1 << 4)
 
 #define        DSP_DIGITMODE_DTMF                      0                               /* Detect DTMF digits */
 #define DSP_DIGITMODE_MF                       1                               /* Detect MF digits */
 
 #define        DSP_DIGITMODE_DTMF                      0                               /* Detect DTMF digits */
 #define DSP_DIGITMODE_MF                       1                               /* Detect MF digits */