summaryrefslogtreecommitdiff
path: root/apps/app_fax.c
diff options
context:
space:
mode:
authorKevin P. Fleming <kpfleming@digium.com>2009-06-16 21:10:15 +0000
committerKevin P. Fleming <kpfleming@digium.com>2009-06-16 21:10:15 +0000
commitf1dc620467d9b218ad5041b6416bb030aec9c68c (patch)
treeb922d4113cce5ce50a4adcda3b8bcf400ab25b47 /apps/app_fax.c
parent5b2939916fe602bb9dfd2ff6c5d40a594b3bd768 (diff)
Enable applications to enable/disable digit and tone detection.
Some applications (notably app_fax) do not need digit detection nor FAX tone detection while they are running, and if Asterisk is using software DSPs to provide the detection, this consumes extra CPU cycles that could be better spent on the actual application. This patch allows applications to query and control the state of digit and tone detection on a channel, and modifies app_fax to disable them while the FAX operations are occurring (and re-enable digit detection afterwards). git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@201139 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps/app_fax.c')
-rw-r--r--apps/app_fax.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/apps/app_fax.c b/apps/app_fax.c
index bd6bdf9f6..e2b7a90ee 100644
--- a/apps/app_fax.c
+++ b/apps/app_fax.c
@@ -710,6 +710,7 @@ static int sndfax_exec(struct ast_channel *chan, const char *data)
int res = 0;
char *parse;
fax_session session;
+ char restore_digit_detect = 0;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(file_name);
@@ -744,8 +745,32 @@ static int sndfax_exec(struct ast_channel *chan, const char *data)
session.chan = chan;
session.finished = 0;
+ /* get current digit detection mode, then disable digit detection if enabled */
+ {
+ int dummy = sizeof(restore_digit_detect);
+
+ ast_channel_queryoption(chan, AST_OPTION_DIGIT_DETECT, &restore_digit_detect, &dummy, 0);
+ }
+
+ if (restore_digit_detect) {
+ char new_digit_detect = 0;
+
+ ast_channel_setoption(chan, AST_OPTION_DIGIT_DETECT, &new_digit_detect, sizeof(new_digit_detect), 0);
+ }
+
+ /* disable FAX tone detection if enabled */
+ {
+ char new_fax_detect = 0;
+
+ ast_channel_setoption(chan, AST_OPTION_FAX_DETECT, &new_fax_detect, sizeof(new_fax_detect), 0);
+ }
+
res = transmit(&session);
+ if (restore_digit_detect) {
+ ast_channel_setoption(chan, AST_OPTION_DIGIT_DETECT, &restore_digit_detect, sizeof(restore_digit_detect), 0);
+ }
+
return res;
}
@@ -754,6 +779,7 @@ static int rcvfax_exec(struct ast_channel *chan, const char *data)
int res = 0;
char *parse;
fax_session session;
+ char restore_digit_detect = 0;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(file_name);
@@ -788,8 +814,32 @@ static int rcvfax_exec(struct ast_channel *chan, const char *data)
session.chan = chan;
session.finished = 0;
+ /* get current digit detection mode, then disable digit detection if enabled */
+ {
+ int dummy = sizeof(restore_digit_detect);
+
+ ast_channel_queryoption(chan, AST_OPTION_DIGIT_DETECT, &restore_digit_detect, &dummy, 0);
+ }
+
+ if (restore_digit_detect) {
+ char new_digit_detect = 0;
+
+ ast_channel_setoption(chan, AST_OPTION_DIGIT_DETECT, &new_digit_detect, sizeof(new_digit_detect), 0);
+ }
+
+ /* disable FAX tone detection if enabled */
+ {
+ char new_fax_detect = 0;
+
+ ast_channel_setoption(chan, AST_OPTION_FAX_DETECT, &new_fax_detect, sizeof(new_fax_detect), 0);
+ }
+
res = transmit(&session);
+ if (restore_digit_detect) {
+ ast_channel_setoption(chan, AST_OPTION_DIGIT_DETECT, &restore_digit_detect, sizeof(restore_digit_detect), 0);
+ }
+
return res;
}