aboutsummaryrefslogtreecommitdiffstats
path: root/channels/chan_modem_i4l.c
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2005-03-26 07:12:19 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2005-03-26 07:12:19 +0000
commit27989646244a77d19b4f67a679912239ea49d67b (patch)
treefa0f0679389d7f5a3862cf3c7ce3a362e14012e3 /channels/chan_modem_i4l.c
parent3b2a896e6f97ed14d3c4e07c6a4e39976a584733 (diff)
Implement fax detect within i4l (bug #3827)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@5265 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_modem_i4l.c')
-rwxr-xr-xchannels/chan_modem_i4l.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/channels/chan_modem_i4l.c b/channels/chan_modem_i4l.c
index d268d9c58..bb032e2b5 100755
--- a/channels/chan_modem_i4l.c
+++ b/channels/chan_modem_i4l.c
@@ -27,6 +27,7 @@
#include <asterisk/dsp.h>
#include <asterisk/callerid.h>
#include <asterisk/ulaw.h>
+#include <asterisk/pbx.h>
#define STATE_COMMAND 0
#define STATE_VOICE 1
@@ -105,7 +106,7 @@ static int i4l_startrec(struct ast_modem_pvt *p)
p->dsp = ast_dsp_new();
if (p->dsp) {
ast_log(LOG_DEBUG, "Detecting DTMF inband with sw DSP on %s\n",p->dev);
- ast_dsp_set_features(p->dsp, DSP_FEATURE_DTMF_DETECT);
+ ast_dsp_set_features(p->dsp, DSP_FEATURE_DTMF_DETECT|DSP_FEATURE_FAX_DETECT);
ast_dsp_digitmode(p->dsp, DSP_DIGITMODE_DTMF | 0);
}
}
@@ -451,6 +452,29 @@ static struct ast_frame *i4l_read(struct ast_modem_pvt *p)
f = ast_dsp_process(p->owner, p->dsp, &p->fr);
if (f && (f->frametype == AST_FRAME_DTMF)) {
ast_log(LOG_DEBUG, "Detected inband DTMF digit: %c on %s\n", f->subclass, p->dev);
+ if (f->subclass == 'f') {
+ /* Fax tone -- Handle and return NULL */
+ struct ast_channel *ast = p->owner;
+ if (!p->faxhandled) {
+ p->faxhandled++;
+ if (strcmp(ast->exten, "fax")) {
+ if (ast_exists_extension(ast, ast_strlen_zero(ast->macrocontext) ? ast->context : ast->macrocontext, "fax", 1, ast->cid.cid_num)) {
+ if (option_verbose > 2)
+ ast_verbose(VERBOSE_PREFIX_3 "Redirecting %s to fax extension\n", ast->name);
+ /* Save the DID/DNIS when we transfer the fax call to a "fax" extension */
+ pbx_builtin_setvar_helper(ast,"FAXEXTEN",ast->exten);
+ if (ast_async_goto(ast, ast->context, "fax", 1))
+ ast_log(LOG_WARNING, "Failed to async goto '%s' into fax of '%s'\n", ast->name, ast->context);
+ } else
+ ast_log(LOG_NOTICE, "Fax detected, but no fax extension\n");
+ } else
+ ast_log(LOG_DEBUG, "Already in a fax extension, not redirecting\n");
+ } else
+ ast_log(LOG_DEBUG, "Fax already handled\n");
+ p->fr.frametype = AST_FRAME_NULL;
+ p->fr.subclass = 0;
+ f = &p->fr;
+ }
return f;
}
}
@@ -553,7 +577,7 @@ static int i4l_answer(struct ast_modem_pvt *p)
p->dsp = ast_dsp_new();
if (p->dsp) {
ast_log(LOG_DEBUG, "Detecting DTMF inband with sw DSP on %s\n",p->dev);
- ast_dsp_set_features(p->dsp, DSP_FEATURE_DTMF_DETECT);
+ ast_dsp_set_features(p->dsp, DSP_FEATURE_DTMF_DETECT|DSP_FEATURE_FAX_DETECT);
ast_dsp_digitmode(p->dsp, DSP_DIGITMODE_DTMF | 0);
}
}