From f105351643320fd12fa0faa9aebb7c6a404d7105 Mon Sep 17 00:00:00 2001
From: Mark Spencer <markster@digium.com>
Date: Tue, 8 Jun 2004 22:34:25 +0000
Subject: [PATCH] Make fax detect configurable by direction (bug #1803)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@3174 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 channels/chan_zap.c        | 13 ++++++++++---
 configs/zapata.conf.sample |  7 +++++--
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/channels/chan_zap.c b/channels/chan_zap.c
index 835f37ebc0..58a67ddf04 100755
--- a/channels/chan_zap.c
+++ b/channels/chan_zap.c
@@ -4200,7 +4200,8 @@ static struct ast_channel *zt_new(struct zt_pvt *i, int state, int startpbx, int
 		if ((i->callprogress & 1) && CANPROGRESSDETECT(i)) {
 			features |= DSP_FEATURE_CALL_PROGRESS;
 		}
-		if (i->callprogress & 2) {
+		if ((!i->outgoing && (i->callprogress & 4)) || 
+		    (i->outgoing && (i->callprogress & 2))) {
 			features |= DSP_FEATURE_FAX_DETECT;
 		}
 		features |= DSP_FEATURE_DTMF_DETECT;
@@ -8413,10 +8414,16 @@ static int setup_zap(void)
 			else
 				callprogress &= ~1;
 		} else if (!strcasecmp(v->name, "faxdetect")) {
-			if (ast_true(v->value))
+			if (!strcasecmp(v->value, "incoming")) {
+				callprogress |= 4;
+				callprogress &= ~2;
+			} else if (!strcasecmp(v->value, "outgoing")) {
+				callprogress &= ~4;
 				callprogress |= 2;
+			} else if (!strcasecmp(v->value, "both") || ast_true(v->value))
+				callprogress |= 6;
 			else
-				callprogress &= ~2;
+				callprogress &= ~6;
 		} else if (!strcasecmp(v->name, "echocancel")) {
 			if (v->value && !ast_strlen_zero(v->value)) {
 				y = atoi(v->value);
diff --git a/configs/zapata.conf.sample b/configs/zapata.conf.sample
index 18e75eee07..f6a9d43bff 100755
--- a/configs/zapata.conf.sample
+++ b/configs/zapata.conf.sample
@@ -279,9 +279,12 @@ immediate=no
 ;callprogress=yes
 ;progzone=us
 ;
-; For fax detection, uncomment the following line.  The default is *OFF*
+; For fax detection, uncomment one of the following lines.  The default is *OFF*
 ;
-;faxdetect=yes
+;faxdetect=both
+;faxdetect=incoming
+;faxdetect=outgoing
+;faxdetect=no
 ;
 ; Select which class of music to use for music on hold.  If not specified
 ; then the default will be used.
-- 
GitLab