summaryrefslogtreecommitdiff
path: root/main/app.c
diff options
context:
space:
mode:
authorMatthew Jordan <mjordan@digium.com>2011-09-20 23:02:25 +0000
committerMatthew Jordan <mjordan@digium.com>2011-09-20 23:02:25 +0000
commite218748ac1ef5158b110e7549152ab11e1418273 (patch)
tree2101d23bfa882dd05e93a448cbd188aafccae752 /main/app.c
parent1313c1284700f2cb9882b4390989e10a4b51df00 (diff)
Merged revisions 337120 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/10 ................ r337120 | mjordan | 2011-09-20 17:49:36 -0500 (Tue, 20 Sep 2011) | 28 lines Merged revisions 337118 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.8 ........ r337118 | mjordan | 2011-09-20 17:38:54 -0500 (Tue, 20 Sep 2011) | 21 lines Fix for incorrect voicemail duration in external notifications This patch fixes an issue where the voicemail duration was being reported with a duration significantly less than the actual sound file duration. Voicemails that contained mostly silence were reporting the duration of only the sound in the file, as opposed to the duration of the file with the silence. This patch fixes this by having two durations reported in the __ast_play_and_record family of functions - the sound_duration and the actual duration of the file. The sound_duration, which is optional, now reports the duration of the sound in the file, while the actual full duration of the file is reported in the duration parameter. This allows the voicemail applications to use the sound_duration for minimum duration checking, while reporting the full duration to external parties if the voicemail is kept. (issue ASTERISK-2234) (closes issue ASTERISK-16981) Reported by: Mary Ciuciu, Byron Clark, Brad House, Karsten Wemheuer, KevinH Tested by: Matt Jordan Review: https://reviewboard.asterisk.org/r/1443 ........ ................ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@337124 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/app.c')
-rw-r--r--main/app.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/main/app.c b/main/app.c
index a48935e8f..367a78387 100644
--- a/main/app.c
+++ b/main/app.c
@@ -721,6 +721,7 @@ static int global_maxsilence = 0;
* \param maxtime Maximum length of recording (in seconds).
* \param fmt Format(s) to record message in. Multiple formats may be specified by separating them with a '|'.
* \param duration Where to store actual length of the recorded message (in milliseconds).
+ * \param sound_duration Where to store the length of the recorded message (in milliseconds), minus any silence
* \param beep Whether to play a beep before starting to record.
* \param silencethreshold
* \param maxsilence Length of silence that will end a recording (in milliseconds).
@@ -735,7 +736,7 @@ static int global_maxsilence = 0;
* \retval 't' Recording ended from the message exceeding the maximum duration, or via DTMF in prepend mode
* \retval dtmfchar Recording ended via the return value's DTMF character for either cancel or accept.
*/
-static int __ast_play_and_record(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime, const char *fmt, int *duration, int beep, int silencethreshold, int maxsilence, const char *path, int prepend, const char *acceptdtmf, const char *canceldtmf, int skip_confirmation_sound)
+static int __ast_play_and_record(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime, const char *fmt, int *duration, int *sound_duration, int beep, int silencethreshold, int maxsilence, const char *path, int prepend, const char *acceptdtmf, const char *canceldtmf, int skip_confirmation_sound)
{
int d = 0;
char *fmts;
@@ -956,6 +957,9 @@ static int __ast_play_and_record(struct ast_channel *chan, const char *playfile,
* closed (which would create a resource leak).
*/
*duration = others[0] ? ast_tellstream(others[0]) / 8000 : 0;
+ if (sound_duration) {
+ *sound_duration = *duration;
+ }
if (!prepend) {
/* Reduce duration by a total silence amount */
@@ -963,12 +967,23 @@ static int __ast_play_and_record(struct ast_channel *chan, const char *playfile,
totalsilence += dspsilence;
}
- if (totalsilence > 0) {
- *duration -= (totalsilence - 200) / 1000;
+ if (sound_duration) {
+ if (totalsilence > 0) {
+ *sound_duration -= (totalsilence - 200) / 1000;
+ }
+ if (*sound_duration < 0) {
+ *sound_duration = 0;
+ }
}
+
+ if (dspsilence > 0) {
+ *duration -= (dspsilence - 200) / 1000;
+ }
+
if (*duration < 0) {
*duration = 0;
}
+
for (x = 0; x < fmtcnt; x++) {
if (!others[x]) {
break;
@@ -1029,19 +1044,19 @@ static int __ast_play_and_record(struct ast_channel *chan, const char *playfile,
static const char default_acceptdtmf[] = "#";
static const char default_canceldtmf[] = "";
-int ast_play_and_record_full(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime, const char *fmt, int *duration, int silencethreshold, int maxsilence, const char *path, const char *acceptdtmf, const char *canceldtmf)
+int ast_play_and_record_full(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime, const char *fmt, int *duration, int *sound_duration, int silencethreshold, int maxsilence, const char *path, const char *acceptdtmf, const char *canceldtmf)
{
- return __ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, 0, silencethreshold, maxsilence, path, 0, S_OR(acceptdtmf, default_acceptdtmf), S_OR(canceldtmf, default_canceldtmf), 0);
+ return __ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, sound_duration, 0, silencethreshold, maxsilence, path, 0, S_OR(acceptdtmf, default_acceptdtmf), S_OR(canceldtmf, default_canceldtmf), 0);
}
-int ast_play_and_record(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime, const char *fmt, int *duration, int silencethreshold, int maxsilence, const char *path)
+int ast_play_and_record(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime, const char *fmt, int *duration, int *sound_duration, int silencethreshold, int maxsilence, const char *path)
{
- return __ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, 0, silencethreshold, maxsilence, path, 0, default_acceptdtmf, default_canceldtmf, 0);
+ return __ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, sound_duration, 0, silencethreshold, maxsilence, path, 0, default_acceptdtmf, default_canceldtmf, 0);
}
-int ast_play_and_prepend(struct ast_channel *chan, char *playfile, char *recordfile, int maxtime, char *fmt, int *duration, int beep, int silencethreshold, int maxsilence)
+int ast_play_and_prepend(struct ast_channel *chan, char *playfile, char *recordfile, int maxtime, char *fmt, int *duration, int *sound_duration, int beep, int silencethreshold, int maxsilence)
{
- return __ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, beep, silencethreshold, maxsilence, NULL, 1, default_acceptdtmf, default_canceldtmf, 1);
+ return __ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, sound_duration, beep, silencethreshold, maxsilence, NULL, 1, default_acceptdtmf, default_canceldtmf, 1);
}
/* Channel group core functions */
@@ -1578,7 +1593,7 @@ int ast_record_review(struct ast_channel *chan, const char *playfile, const char
/* Record */
ast_verb(3, "R%secording\n", recorded == 1 ? "e-r" : "");
recorded = 1;
- if ((cmd = ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, silencethreshold, maxsilence, path)) == -1) {
+ if ((cmd = ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, NULL, silencethreshold, maxsilence, path)) == -1) {
/* User has hung up, no options to give */
return cmd;
}