mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-24 13:50:08 +00:00
https://origsvn.digium.com/svn/asterisk/trunk ................ r147518 | file | 2008-10-08 09:53:51 -0500 (Wed, 08 Oct 2008) | 9 lines Merged revisions 147517 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r147517 | file | 2008-10-08 11:51:42 -0300 (Wed, 08 Oct 2008) | 2 lines If we receive DTMF make sure that the state of the speech structure goes back to being not ready. (issue #LUMENVOX-8) ........ ................ r147689 | kpfleming | 2008-10-08 17:26:55 -0500 (Wed, 08 Oct 2008) | 9 lines Merged revisions 147681 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r147681 | kpfleming | 2008-10-08 17:22:09 -0500 (Wed, 08 Oct 2008) | 3 lines when parsing a text configuration option, ensure that the buffer on the stack is actually large enough to hold the legal values of that option, and also ensure that sscanf() knows to stop parsing if it would overrun the buffer (without these changes, specifying "buffers=...,immediate" would overflow the buffer on the stack, and could not have worked as expected) ........ ................ r148000 | tilghman | 2008-10-09 14:39:34 -0500 (Thu, 09 Oct 2008) | 11 lines Merged revisions 147997 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r147997 | tilghman | 2008-10-09 14:38:33 -0500 (Thu, 09 Oct 2008) | 4 lines When blank, callerid name and number should display "unknown caller" in voicemail emails. (Closes issue #13643) ........ ................ r148112 | mmichelson | 2008-10-09 18:15:33 -0500 (Thu, 09 Oct 2008) | 26 lines Merged revisions 146026 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r146026 | murf | 2008-10-03 12:12:54 -0500 (Fri, 03 Oct 2008) | 18 lines (closes issue #13579) Reported by: dwagner (closes issue #13584) Reported by: dwagner Tested by: murf, putnopvut The thought occurred to me that the res= from the extension spawn was ending up being returned from the bridge. "Thou shalt not poison the return value". Made the change and it appears to allow blind xfers to work as normal. If I'm wrong, reopen the bugs. But it looks good to me! Many thanks to putnopvut for helping me reproduce this! ........ ................ r148268 | tilghman | 2008-10-10 11:31:31 -0500 (Fri, 10 Oct 2008) | 14 lines Merged revisions 148257 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r148257 | tilghman | 2008-10-10 11:25:31 -0500 (Fri, 10 Oct 2008) | 7 lines User not notified of temporary greeting, if ODBC storage is in use. (closes issue #13659) Reported by: moliveras Patches: 20081009__bug13659.diff.txt uploaded by Corydon76 (license 14) Tested by: moliveras ........ ................ r148917 | tilghman | 2008-10-14 12:46:48 -0500 (Tue, 14 Oct 2008) | 11 lines Merged revisions 148916 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r148916 | tilghman | 2008-10-14 12:41:08 -0500 (Tue, 14 Oct 2008) | 4 lines Ensure that mail headers are 7-bit clean, even when UTF-8 characters are used in headers like 'Subject' and 'To'. Closes AST-107. ........ ................ r148988 | tilghman | 2008-10-14 14:03:44 -0500 (Tue, 14 Oct 2008) | 9 lines Merged revisions 148987 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r148987 | tilghman | 2008-10-14 14:03:08 -0500 (Tue, 14 Oct 2008) | 2 lines Some compilers warn, some don't. Fixing. ........ ................ r149062 | tilghman | 2008-10-14 15:16:48 -0500 (Tue, 14 Oct 2008) | 13 lines Merged revisions 149061 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r149061 | tilghman | 2008-10-14 15:09:06 -0500 (Tue, 14 Oct 2008) | 6 lines Check correct values in the return of ast_waitfor(); also, get rid of a possible memory leak. (closes issue #13658) Reported by: explidous Patch by: me ........ ................ r149131 | mmichelson | 2008-10-14 16:08:48 -0500 (Tue, 14 Oct 2008) | 15 lines Merged revisions 149130 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r149130 | mmichelson | 2008-10-14 15:49:02 -0500 (Tue, 14 Oct 2008) | 7 lines Don't allow reserved characters to be used in register lines in sip.conf. (closes issue #13570) Reported by: putnopvut ........ ................ r149201 | mmichelson | 2008-10-14 17:41:13 -0500 (Tue, 14 Oct 2008) | 20 lines Merged revisions 149200 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r149200 | mmichelson | 2008-10-14 17:40:42 -0500 (Tue, 14 Oct 2008) | 12 lines Update the queue with the correct number of calls and whether the call was completed within the service level when a transfer takes place. This way, we do not "break" the leastrecent and fewestcalls strategies by not logging a call until after the transferred call has ended. (closes issue #13395) Reported by: Marquis Patches: app_queue.c.transfer.patch uploaded by Marquis (license 32) ........ ................ r149205 | mmichelson | 2008-10-14 18:04:44 -0500 (Tue, 14 Oct 2008) | 20 lines Merged revisions 149204 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r149204 | mmichelson | 2008-10-14 18:00:01 -0500 (Tue, 14 Oct 2008) | 12 lines Add a tolerance period for sync-triggered audiohooks so that if packetization of audio is close (but not equal) we don't end up flushing the audiohooks over small inconsistencies in synchronization. Related to issue #13005, and solves the issue for most people who were experiencing the problem. However, a small number of people are still experiencing the problem on long calls, so I am not closing the issue yet ........ ................ r149208 | mmichelson | 2008-10-14 18:15:04 -0500 (Tue, 14 Oct 2008) | 17 lines Merged revisions 149207 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r149207 | mmichelson | 2008-10-14 18:10:26 -0500 (Tue, 14 Oct 2008) | 9 lines Call register_peer_exten even in the case that the peer's IP/port does not change. (closes issue #13309) Reported by: dimas Patches: v2-13309.patch uploaded by dimas (license 88) ........ ................ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.0@160387 65c4cc65-6c06-0410-ace0-fbb531ad65f3
189 lines
6.0 KiB
C
189 lines
6.0 KiB
C
/*
|
|
* Asterisk -- An open source telephony toolkit.
|
|
*
|
|
* Copyright (C) 1999 - 2005, Digium, Inc.
|
|
*
|
|
* WaitForSilence Application by David C. Troy <dave@popvox.com>
|
|
* Version 1.11 2006-06-29
|
|
*
|
|
* Mark Spencer <markster@digium.com>
|
|
*
|
|
* See http://www.asterisk.org for more information about
|
|
* the Asterisk project. Please do not directly contact
|
|
* any of the maintainers of this project for assistance;
|
|
* the project provides a web site, mailing lists and IRC
|
|
* channels for your use.
|
|
*
|
|
* This program is free software, distributed under the terms of
|
|
* the GNU General Public License Version 2. See the LICENSE file
|
|
* at the top of the source tree.
|
|
*/
|
|
|
|
/*! \file
|
|
*
|
|
* \brief Wait for Silence
|
|
* - Waits for up to 'x' milliseconds of silence, 'y' times \n
|
|
* - WaitForSilence(500,2) will wait for 1/2 second of silence, twice \n
|
|
* - WaitForSilence(1000,1) will wait for 1 second of silence, once \n
|
|
* - WaitForSilence(300,3,10) will wait for 300ms of silence, 3 times, and return after 10sec \n
|
|
*
|
|
* \author David C. Troy <dave@popvox.com>
|
|
*
|
|
* \ingroup applications
|
|
*/
|
|
|
|
#include "asterisk.h"
|
|
|
|
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|
|
|
#include "asterisk/file.h"
|
|
#include "asterisk/channel.h"
|
|
#include "asterisk/pbx.h"
|
|
#include "asterisk/dsp.h"
|
|
#include "asterisk/module.h"
|
|
|
|
static char *app = "WaitForSilence";
|
|
static char *synopsis = "Waits for a specified amount of silence";
|
|
static char *descrip =
|
|
" WaitForSilence(silencerequired[,iterations][,timeout]):\n"
|
|
"Wait for Silence: Waits for up to 'silencerequired' \n"
|
|
"milliseconds of silence, 'iterations' times or once if omitted.\n"
|
|
"An optional timeout specified the number of seconds to return\n"
|
|
"after, even if we do not receive the specified amount of silence.\n"
|
|
"Use 'timeout' with caution, as it may defeat the purpose of this\n"
|
|
"application, which is to wait indefinitely until silence is detected\n"
|
|
"on the line. This is particularly useful for reverse-911-type\n"
|
|
"call broadcast applications where you need to wait for an answering\n"
|
|
"machine to complete its spiel before playing a message.\n"
|
|
"The timeout parameter is specified only to avoid an infinite loop in\n"
|
|
"cases where silence is never achieved. Typically you will want to\n"
|
|
"include two or more calls to WaitForSilence when dealing with an answering\n"
|
|
"machine; first waiting for the spiel to finish, then waiting for the beep, etc.\n\n"
|
|
"Examples:\n"
|
|
" - WaitForSilence(500,2) will wait for 1/2 second of silence, twice\n"
|
|
" - WaitForSilence(1000) will wait for 1 second of silence, once\n"
|
|
" - WaitForSilence(300,3,10) will wait for 300ms silence, 3 times,\n"
|
|
" and returns after 10 sec, even if silence is not detected\n\n"
|
|
"Sets the channel variable WAITSTATUS with to one of these values:\n"
|
|
"SILENCE - if exited with silence detected\n"
|
|
"TIMEOUT - if exited without silence detected after timeout\n";
|
|
|
|
static int do_waiting(struct ast_channel *chan, int silencereqd, time_t waitstart, int timeout) {
|
|
struct ast_frame *f = NULL;
|
|
int dspsilence = 0;
|
|
static int silencethreshold = 128;
|
|
int rfmt = 0;
|
|
int res = 0;
|
|
struct ast_dsp *sildet; /* silence detector dsp */
|
|
time_t now;
|
|
|
|
rfmt = chan->readformat; /* Set to linear mode */
|
|
if ((res = ast_set_read_format(chan, AST_FORMAT_SLINEAR)) < 0) {
|
|
ast_log(LOG_WARNING, "Unable to set channel to linear mode, giving up\n");
|
|
return -1;
|
|
}
|
|
|
|
/* Create the silence detector */
|
|
if (!(sildet = ast_dsp_new())) {
|
|
ast_log(LOG_WARNING, "Unable to create silence detector :(\n");
|
|
return -1;
|
|
}
|
|
ast_dsp_set_threshold(sildet, silencethreshold);
|
|
|
|
/* Await silence... */
|
|
for (;;) {
|
|
/* Start with no silence received */
|
|
dspsilence = 0;
|
|
|
|
res = ast_waitfor(chan, silencereqd);
|
|
|
|
/* Must have gotten a hangup; let's exit */
|
|
if (res < 0) {
|
|
pbx_builtin_setvar_helper(chan, "WAITSTATUS", "HANGUP");
|
|
break;
|
|
}
|
|
|
|
/* We waited and got no frame; sounds like digital silence or a muted digital channel */
|
|
if (res == 0) {
|
|
dspsilence = silencereqd;
|
|
} else {
|
|
/* Looks like we did get a frame, so let's check it out */
|
|
if (!(f = ast_read(chan))) {
|
|
pbx_builtin_setvar_helper(chan, "WAITSTATUS", "HANGUP");
|
|
break;
|
|
}
|
|
if (f->frametype == AST_FRAME_VOICE) {
|
|
ast_dsp_silence(sildet, f, &dspsilence);
|
|
}
|
|
ast_frfree(f);
|
|
}
|
|
|
|
ast_verb(6, "Got %dms silence< %dms required\n", dspsilence, silencereqd);
|
|
|
|
if (dspsilence >= silencereqd) {
|
|
ast_verb(3, "Exiting with %dms silence >= %dms required\n", dspsilence, silencereqd);
|
|
/* Ended happily with silence */
|
|
res = 1;
|
|
pbx_builtin_setvar_helper(chan, "WAITSTATUS", "SILENCE");
|
|
ast_debug(1, "WAITSTATUS was set to SILENCE\n");
|
|
break;
|
|
}
|
|
|
|
if ( timeout && (difftime(time(&now),waitstart) >= timeout) ) {
|
|
pbx_builtin_setvar_helper(chan, "WAITSTATUS", "TIMEOUT");
|
|
ast_debug(1, "WAITSTATUS was set to TIMEOUT\n");
|
|
res = 0;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
if (rfmt && ast_set_read_format(chan, rfmt)) {
|
|
ast_log(LOG_WARNING, "Unable to restore format %s to channel '%s'\n", ast_getformatname(rfmt), chan->name);
|
|
}
|
|
ast_dsp_free(sildet);
|
|
return res;
|
|
}
|
|
|
|
static int waitforsilence_exec(struct ast_channel *chan, void *data)
|
|
{
|
|
int res = 1;
|
|
int silencereqd = 1000;
|
|
int timeout = 0;
|
|
int iterations = 1, i;
|
|
time_t waitstart;
|
|
|
|
res = ast_answer(chan); /* Answer the channel */
|
|
|
|
if (!data || ( (sscanf(data, "%d,%d,%d", &silencereqd, &iterations, &timeout) != 3) &&
|
|
(sscanf(data, "%d|%d", &silencereqd, &iterations) != 2) &&
|
|
(sscanf(data, "%d", &silencereqd) != 1) ) ) {
|
|
ast_log(LOG_WARNING, "Using default value of 1000ms, 1 iteration, no timeout\n");
|
|
}
|
|
|
|
ast_verb(3, "Waiting %d time(s) for %d ms silence with %d timeout\n", iterations, silencereqd, timeout);
|
|
|
|
time(&waitstart);
|
|
res = 1;
|
|
for (i=0; (i<iterations) && (res == 1); i++) {
|
|
res = do_waiting(chan, silencereqd, waitstart, timeout);
|
|
}
|
|
if (res > 0)
|
|
res = 0;
|
|
return res;
|
|
}
|
|
|
|
|
|
static int unload_module(void)
|
|
{
|
|
return ast_unregister_application(app);
|
|
}
|
|
|
|
static int load_module(void)
|
|
{
|
|
return ast_register_application(app, waitforsilence_exec, synopsis, descrip);
|
|
}
|
|
|
|
AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Wait For Silence");
|
|
|