[-]
[+]
|
Added |
app_nv_faxdetect.c.1.4.patch
|
@@ -0,0 +1,43 @@
+--- app_nv_faxdetect.c.old 2006-02-24 04:52:29.000000000 +0100-+
++++ app_nv_faxdetect.c 2007-08-16 03:40:21.000000000 +0200
+@@ -77,7 +77,7 @@
+ static int nv_detectfax_exec(struct ast_channel *chan, void *data)
+ {
+ int res = 0;
+- struct localuser *u;
++ //struct localuser *u;
+ char tmp256 = "\0";
+ char *p = NULL;
+ char *waitstr = NULL;
+@@ -157,7 +157,7 @@
+ ast_log(LOG_DEBUG, "Preparing detect of fax (waitdur=%dms, sildur=%dms, mindur=%dms, maxdur=%dms)\n",
+ waitdur, sildur, mindur, maxdur);
+
+- LOCAL_USER_ADD(u);
++ //LOCAL_USER_ADD(u);
+ if (chan->_state != AST_STATE_UP && !skipanswer) {
+ /* Otherwise answer unless we're supposed to send this while on-hook */
+ res = ast_answer(chan);
+@@ -307,14 +307,14 @@
+ if (dsp)
+ ast_dsp_free(dsp);
+
+- LOCAL_USER_REMOVE(u);
++ //LOCAL_USER_REMOVE(u);
+
+ return res;
+ }
+
+ int unload_module(void)
+ {
+- STANDARD_HANGUP_LOCALUSERS;
++ //STANDARD_HANGUP_LOCALUSERS;
+ return ast_unregister_application(app);
+ }
+
+@@ -339,3 +339,5 @@
+ {
+ return ASTERISK_GPL_KEY;
+ }
++
++AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Fax detection application");
|
[-]
[+]
|
Added |
app_nv_faxdetect.c
^
|
@@ -0,0 +1,341 @@
+/*
+ * Asterisk -- A telephony toolkit for Linux.
+ *
+ * Fax detection application for all channel types.
+ *
+ * Copyright (C) 2004-2005, Newman Telecom, Inc. and Newman Ventures, Inc.
+ *
+ * Justin Newman <jnewman@newmantelecom.com>
+ *
+ * We would like to thank Newman Ventures, Inc. for funding this
+ * Asterisk project.
+ *
+ * Newman Ventures <info@newmanventures.com>
+ *
+ * Portions Copyright:
+ * Copyright (C) 2001, Linux Support Services, Inc.
+ * Copyright (C) 2004, Digium, Inc.
+ *
+ * Matthew Fredrickson <creslin@linux-support.net>
+ * Mark Spencer <markster@digium.com>
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License
+ */
+
+#include <stdio.h>
+#include <asterisk/lock.h>
+#include <asterisk/file.h>
+#include <asterisk/logger.h>
+#include <asterisk/channel.h>
+#include <asterisk/pbx.h>
+#include <asterisk/module.h>
+#include <asterisk/translate.h>
+#include <asterisk/dsp.h>
+#include <asterisk/utils.h>
+#include <string.h>
+#include <stdlib.h>
+
+static char *tdesc = "Newman's fax detection application";
+
+static char *app = "NVFaxDetect";
+
+static char *synopsis = "Detects fax sounds on all channel types (IAX and SIP too)";
+
+static char *descrip =
+" NVFaxDetect([waitdur[|options[|sildur[|mindur[|maxdur]]]]]):\n"
+"This application listens for fax tones (on IAX and SIP channels too)\n"
+"for waitdur seconds of time. In addition, it can be interrupted by digits,\n"
+"or non-silence. Audio is only monitored in the receive direction. If\n"
+"digits interrupt, they must be the start of a valid extension unless the\n"
+"option is included to ignore. If fax is detected, it will jump to the\n"
+"'fax' extension. If a period of non-silence greater than 'mindur' ms,\n"
+"yet less than 'maxdur' ms is followed by silence at least 'sildur' ms\n"
+"then the app is aborted and processing jumps to the 'talk' extension.\n"
+"If all undetected, control will continue at the next priority.\n"
+" waitdur: Maximum number of seconds to wait (default=4)\n"
+" options:\n"
+" 'n': Attempt on-hook if unanswered (default=no)\n"
+" 'x': DTMF digits terminate without extension (default=no)\n"
+" 'd': Ignore DTMF digit detection (default=no)\n"
+" 'f': Ignore fax detection (default=no)\n"
+" 't': Ignore talk detection (default=no)\n"
+" sildur: Silence ms after mindur/maxdur before aborting (default=1000)\n"
+" mindur: Minimum non-silence ms needed (default=100)\n"
+" maxdur: Maximum non-silence ms allowed (default=0/forever)\n"
+"Returns -1 on hangup, and 0 on successful completion with no exit conditions.\n\n"
+"For questions or comments, please e-mail support@newmantelecom.com.\n";
+
+// Use the second one for recent Asterisk releases
+#define CALLERID_FIELD cid.cid_num
+//#define CALLERID_FIELD callerid
+
+STANDARD_LOCAL_USER;
+
+LOCAL_USER_DECL;
+
+static int nv_detectfax_exec(struct ast_channel *chan, void *data)
+{
+ int res = 0;
+ struct localuser *u;
+ char tmp[256] = "\0";
+ char *p = NULL;
+ char *waitstr = NULL;
+ char *options = NULL;
+ char *silstr = NULL;
+ char *minstr = NULL;
+ char *maxstr = NULL;
+ struct ast_frame *fr = NULL;
+ struct ast_frame *fr2 = NULL;
+ int notsilent = 0;
+ struct timeval start = {0, 0}, end = {0, 0};
+ int waitdur = 4;
+ int sildur = 1000;
+ int mindur = 100;
+ int maxdur = -1;
+ int skipanswer = 0;
+ int noextneeded = 0;
+ int ignoredtmf = 0;
+ int ignorefax = 0;
+ int ignoretalk = 0;
+ int x = 0;
+ int origrformat = 0;
+ int features = 0;
+ time_t timeout = 0;
+ struct ast_dsp *dsp = NULL;
+
+ pbx_builtin_setvar_helper(chan, "FAX_DETECTED", "");
+ pbx_builtin_setvar_helper(chan, "FAXEXTEN", "");
+ pbx_builtin_setvar_helper(chan, "DTMF_DETECTED", "");
+ pbx_builtin_setvar_helper(chan, "TALK_DETECTED", "");
+
+ if (data || !ast_strlen_zero((char *)data)) {
+ strncpy(tmp, (char *)data, sizeof(tmp)-1);
+ }
+
+ p = tmp;
+
+ waitstr = strsep(&p, "|");
+ options = strsep(&p, "|");
+ silstr = strsep(&p, "|");
+ minstr = strsep(&p, "|");
+ maxstr = strsep(&p, "|");
+
+ if (waitstr) {
+ if ((sscanf(waitstr, "%d", &x) == 1) && (x > 0))
+ waitdur = x;
+ }
+
+ if (options) {
+ if (strchr(options, 'n'))
+ skipanswer = 1;
+ if (strchr(options, 'x'))
+ noextneeded = 1;
+ if (strchr(options, 'd'))
+ ignoredtmf = 1;
+ if (strchr(options, 'f'))
+ ignorefax = 1;
+ if (strchr(options, 't'))
+ ignoretalk = 1;
+ }
+
+ if (silstr) {
+ if ((sscanf(silstr, "%d", &x) == 1) && (x > 0))
+ sildur = x;
+ }
+
+ if (minstr) {
+ if ((sscanf(minstr, "%d", &x) == 1) && (x > 0))
+ mindur = x;
+ }
+
+ if (maxstr) {
+ if ((sscanf(maxstr, "%d", &x) == 1) && (x > 0))
+ maxdur = x;
+ }
+
+ ast_log(LOG_DEBUG, "Preparing detect of fax (waitdur=%dms, sildur=%dms, mindur=%dms, maxdur=%dms)\n",
+ waitdur, sildur, mindur, maxdur);
+
+ LOCAL_USER_ADD(u);
+ if (chan->_state != AST_STATE_UP && !skipanswer) {
+ /* Otherwise answer unless we're supposed to send this while on-hook */
+ res = ast_answer(chan);
+ }
+ if (!res) {
+ origrformat = chan->readformat;
+ if ((res = ast_set_read_format(chan, AST_FORMAT_SLINEAR)))
+ ast_log(LOG_WARNING, "Unable to set read format to linear!\n");
+ }
+ if (!(dsp = ast_dsp_new())) {
+ ast_log(LOG_WARNING, "Unable to allocate DSP!\n");
+ res = -1;
+ }
+
+ if (dsp) {
+ if (!ignoretalk)
+ ; /* features |= DSP_FEATURE_SILENCE_SUPPRESS; */
+ if (!ignorefax)
+ features |= DSP_FEATURE_FAX_DETECT;
+ //if (!ignoredtmf)
+ features |= DSP_FEATURE_DTMF_DETECT;
+
+ ast_dsp_set_threshold(dsp, 256);
+ ast_dsp_set_features(dsp, features | DSP_DIGITMODE_RELAXDTMF);
+ ast_dsp_digitmode(dsp, DSP_DIGITMODE_DTMF);
+ }
+
+ if (!res) {
+ if (waitdur > 0)
+ timeout = time(NULL) + (time_t)waitdur;
+
+ while(ast_waitfor(chan, -1) > -1) {
+ if (waitdur > 0 && time(NULL) > timeout) {
+ res = 0;
+ break;
+ }
+
+ fr = ast_read(chan);
+ if (!fr) {
|
[-]
[+]
|
Added |
app_nv_faxdetect14.c
^
|
@@ -0,0 +1,343 @@
+/*
+ * Asterisk -- A telephony toolkit for Linux.
+ *
+ * Fax detection application for all channel types.
+ *
+ * Copyright (C) 2004-2005, Newman Telecom, Inc. and Newman Ventures, Inc.
+ *
+ * Justin Newman <jnewman@newmantelecom.com>
+ *
+ * We would like to thank Newman Ventures, Inc. for funding this
+ * Asterisk project.
+ *
+ * Newman Ventures <info@newmanventures.com>
+ *
+ * Portions Copyright:
+ * Copyright (C) 2001, Linux Support Services, Inc.
+ * Copyright (C) 2004, Digium, Inc.
+ *
+ * Matthew Fredrickson <creslin@linux-support.net>
+ * Mark Spencer <markster@digium.com>
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License
+ */
+
+#include <stdio.h>
+#include <asterisk/lock.h>
+#include <asterisk/file.h>
+#include <asterisk/logger.h>
+#include <asterisk/channel.h>
+#include <asterisk/pbx.h>
+#include <asterisk/module.h>
+#include <asterisk/translate.h>
+#include <asterisk/dsp.h>
+#include <asterisk/utils.h>
+#include <string.h>
+#include <stdlib.h>
+
+static char *tdesc = "Newman's fax detection application";
+
+static char *app = "NVFaxDetect";
+
+static char *synopsis = "Detects fax sounds on all channel types (IAX and SIP too)";
+
+static char *descrip =
+" NVFaxDetect([waitdur[|options[|sildur[|mindur[|maxdur]]]]]):\n"
+"This application listens for fax tones (on IAX and SIP channels too)\n"
+"for waitdur seconds of time. In addition, it can be interrupted by digits,\n"
+"or non-silence. Audio is only monitored in the receive direction. If\n"
+"digits interrupt, they must be the start of a valid extension unless the\n"
+"option is included to ignore. If fax is detected, it will jump to the\n"
+"'fax' extension. If a period of non-silence greater than 'mindur' ms,\n"
+"yet less than 'maxdur' ms is followed by silence at least 'sildur' ms\n"
+"then the app is aborted and processing jumps to the 'talk' extension.\n"
+"If all undetected, control will continue at the next priority.\n"
+" waitdur: Maximum number of seconds to wait (default=4)\n"
+" options:\n"
+" 'n': Attempt on-hook if unanswered (default=no)\n"
+" 'x': DTMF digits terminate without extension (default=no)\n"
+" 'd': Ignore DTMF digit detection (default=no)\n"
+" 'f': Ignore fax detection (default=no)\n"
+" 't': Ignore talk detection (default=no)\n"
+" sildur: Silence ms after mindur/maxdur before aborting (default=1000)\n"
+" mindur: Minimum non-silence ms needed (default=100)\n"
+" maxdur: Maximum non-silence ms allowed (default=0/forever)\n"
+"Returns -1 on hangup, and 0 on successful completion with no exit conditions.\n\n"
+"For questions or comments, please e-mail support@newmantelecom.com.\n";
+
+// Use the second one for recent Asterisk releases
+#define CALLERID_FIELD cid.cid_num
+//#define CALLERID_FIELD callerid
+
+STANDARD_LOCAL_USER;
+
+LOCAL_USER_DECL;
+
+static int nv_detectfax_exec(struct ast_channel *chan, void *data)
+{
+ int res = 0;
+ //struct localuser *u;
+ char tmp[256] = "\0";
+ char *p = NULL;
+ char *waitstr = NULL;
+ char *options = NULL;
+ char *silstr = NULL;
+ char *minstr = NULL;
+ char *maxstr = NULL;
+ struct ast_frame *fr = NULL;
+ struct ast_frame *fr2 = NULL;
+ int notsilent = 0;
+ struct timeval start = {0, 0}, end = {0, 0};
+ int waitdur = 4;
+ int sildur = 1000;
+ int mindur = 100;
+ int maxdur = -1;
+ int skipanswer = 0;
+ int noextneeded = 0;
+ int ignoredtmf = 0;
+ int ignorefax = 0;
+ int ignoretalk = 0;
+ int x = 0;
+ int origrformat = 0;
+ int features = 0;
+ time_t timeout = 0;
+ struct ast_dsp *dsp = NULL;
+
+ pbx_builtin_setvar_helper(chan, "FAX_DETECTED", "");
+ pbx_builtin_setvar_helper(chan, "FAXEXTEN", "");
+ pbx_builtin_setvar_helper(chan, "DTMF_DETECTED", "");
+ pbx_builtin_setvar_helper(chan, "TALK_DETECTED", "");
+
+ if (data || !ast_strlen_zero((char *)data)) {
+ strncpy(tmp, (char *)data, sizeof(tmp)-1);
+ }
+
+ p = tmp;
+
+ waitstr = strsep(&p, "|");
+ options = strsep(&p, "|");
+ silstr = strsep(&p, "|");
+ minstr = strsep(&p, "|");
+ maxstr = strsep(&p, "|");
+
+ if (waitstr) {
+ if ((sscanf(waitstr, "%d", &x) == 1) && (x > 0))
+ waitdur = x;
+ }
+
+ if (options) {
+ if (strchr(options, 'n'))
+ skipanswer = 1;
+ if (strchr(options, 'x'))
+ noextneeded = 1;
+ if (strchr(options, 'd'))
+ ignoredtmf = 1;
+ if (strchr(options, 'f'))
+ ignorefax = 1;
+ if (strchr(options, 't'))
+ ignoretalk = 1;
+ }
+
+ if (silstr) {
+ if ((sscanf(silstr, "%d", &x) == 1) && (x > 0))
+ sildur = x;
+ }
+
+ if (minstr) {
+ if ((sscanf(minstr, "%d", &x) == 1) && (x > 0))
+ mindur = x;
+ }
+
+ if (maxstr) {
+ if ((sscanf(maxstr, "%d", &x) == 1) && (x > 0))
+ maxdur = x;
+ }
+
+ ast_log(LOG_DEBUG, "Preparing detect of fax (waitdur=%dms, sildur=%dms, mindur=%dms, maxdur=%dms)\n",
+ waitdur, sildur, mindur, maxdur);
+
+ //LOCAL_USER_ADD(u);
+ if (chan->_state != AST_STATE_UP && !skipanswer) {
+ /* Otherwise answer unless we're supposed to send this while on-hook */
+ res = ast_answer(chan);
+ }
+ if (!res) {
+ origrformat = chan->readformat;
+ if ((res = ast_set_read_format(chan, AST_FORMAT_SLINEAR)))
+ ast_log(LOG_WARNING, "Unable to set read format to linear!\n");
+ }
+ if (!(dsp = ast_dsp_new())) {
+ ast_log(LOG_WARNING, "Unable to allocate DSP!\n");
+ res = -1;
+ }
+
+ if (dsp) {
+ if (!ignoretalk)
+ ; /* features |= DSP_FEATURE_SILENCE_SUPPRESS; */
+ if (!ignorefax)
+ features |= DSP_FEATURE_FAX_DETECT;
+ //if (!ignoredtmf)
+ features |= DSP_FEATURE_DTMF_DETECT;
+
+ ast_dsp_set_threshold(dsp, 256);
+ ast_dsp_set_features(dsp, features | DSP_DIGITMODE_RELAXDTMF);
+ ast_dsp_digitmode(dsp, DSP_DIGITMODE_DTMF);
+ }
+
+ if (!res) {
+ if (waitdur > 0)
+ timeout = time(NULL) + (time_t)waitdur;
+
+ while(ast_waitfor(chan, -1) > -1) {
+ if (waitdur > 0 && time(NULL) > timeout) {
+ res = 0;
+ break;
+ }
+
+ fr = ast_read(chan);
+ if (!fr) {
|
|
Added |
asterisk-1.4.25.tar.bz2
^
|