mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-04 03:50:31 +00:00
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
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user