Ignore voicemail messages that are just silence.

(closes issue #2264)
Reported by: pfn
Patches:
      silent-vm-1.6.2.txt uploaded by pfn (license 810)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@202570 65c4cc65-6c06-0410-ace0-fbb531ad65f3
certified/1.8.6
Russell Bryant 16 years ago
parent 2affa3e999
commit 0bbd5c9424

@ -50,6 +50,8 @@ Applications
to cycle through the next avaliable channel. By default this is still '*'. to cycle through the next avaliable channel. By default this is still '*'.
* Added x() option to app_chanspy. This option allows DTMF to be set to * Added x() option to app_chanspy. This option allows DTMF to be set to
exit the application. exit the application.
* The Voicemail application has been improved to automatically ignore messages
that only contain silence.
Dialplan Functions Dialplan Functions
------------------ ------------------

@ -699,6 +699,7 @@ static int __ast_play_and_record(struct ast_channel *chan, const char *playfile,
time_t start, end; time_t start, end;
struct ast_dsp *sildet = NULL; /* silence detector dsp */ struct ast_dsp *sildet = NULL; /* silence detector dsp */
int totalsilence = 0; int totalsilence = 0;
int dspsilence = 0;
int rfmt = 0; int rfmt = 0;
struct ast_silence_generator *silgen = NULL; struct ast_silence_generator *silgen = NULL;
char prependfile[80]; char prependfile[80];
@ -823,17 +824,13 @@ static int __ast_play_and_record(struct ast_channel *chan, const char *playfile,
/* Silence Detection */ /* Silence Detection */
if (maxsilence > 0) { if (maxsilence > 0) {
int dspsilence = 0; dspsilence = 0;
ast_dsp_silence(sildet, f, &dspsilence); ast_dsp_silence(sildet, f, &dspsilence);
if (dspsilence) { totalsilence += dspsilence;
totalsilence = dspsilence;
} else {
totalsilence = 0;
}
if (totalsilence > maxsilence) { if (dspsilence > maxsilence) {
/* Ended happily with silence */ /* Ended happily with silence */
ast_verb(3, "Recording automatically stopped after a silence of %d seconds\n", totalsilence/1000); ast_verb(3, "Recording automatically stopped after a silence of %d seconds\n", dspsilence/1000);
res = 'S'; res = 'S';
outmsg = 2; outmsg = 2;
break; break;
@ -908,6 +905,12 @@ static int __ast_play_and_record(struct ast_channel *chan, const char *playfile,
*duration = others[0] ? ast_tellstream(others[0]) / 8000 : 0; *duration = others[0] ? ast_tellstream(others[0]) / 8000 : 0;
if (!prepend) { if (!prepend) {
/* Reduce duration by a total silence amount */
if (totalsilence > 0)
*duration -= (totalsilence - 200) / 1000;
if (*duration < 0) {
*duration = 0;
}
for (x = 0; x < fmtcnt; x++) { for (x = 0; x < fmtcnt; x++) {
if (!others[x]) { if (!others[x]) {
break; break;
@ -917,15 +920,9 @@ static int __ast_play_and_record(struct ast_channel *chan, const char *playfile,
* off the recording. However, if we ended with '#', we don't want * off the recording. However, if we ended with '#', we don't want
* to trim ANY part of the recording. * to trim ANY part of the recording.
*/ */
if (res > 0 && totalsilence) { if (res > 0 && dspsilence) {
ast_stream_rewind(others[x], totalsilence - 200); /* rewind only the trailing silence */
/* Reduce duration by a corresponding amount */ ast_stream_rewind(others[x], dspsilence - 200);
if (x == 0 && *duration) {
*duration -= (totalsilence - 200) / 1000;
if (*duration < 0) {
*duration = 0;
}
}
} }
ast_truncstream(others[x]); ast_truncstream(others[x]);
ast_closestream(others[x]); ast_closestream(others[x]);
@ -943,8 +940,8 @@ static int __ast_play_and_record(struct ast_channel *chan, const char *playfile,
break; break;
} }
/*!\note Same logic as above. */ /*!\note Same logic as above. */
if (totalsilence) { if (dspsilence) {
ast_stream_rewind(others[x], totalsilence - 200); ast_stream_rewind(others[x], dspsilence - 200);
} }
ast_truncstream(others[x]); ast_truncstream(others[x]);
/* add the original file too */ /* add the original file too */

Loading…
Cancel
Save