added min_record_time to voicemail, will not send voicemail messages shorter than that.

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@517 8eb893ce-cfd4-0310-b710-fb5ebe64c474
sayer/1.4-spce2.6
Stefan Sayer 19 years ago
parent 7e9f32768c
commit 733e7599bd

@ -58,10 +58,10 @@
#define MOD_NAME "voicemail"
#define DEFAULT_AUDIO_EXT "wav"
#define DEFAULT_MAIL_TMPL_PATH string("/usr/local/etc/sems")
#define DEFAULT_MAIL_TMPL string("default")
#define DEFAULT_MAIL_TMPL_EXT string("template")
#define DEFAULT_MAIL_TMPL_PATH string("/usr/local/etc/sems")
#define DEFAULT_MAIL_TMPL string("default")
#define DEFAULT_MAIL_TMPL_EXT string("template")
#define DEFAULT_MIN_RECORD_TIME 0
#define RECORD_TIMER 99
EXPORT_SESSION_FACTORY(AnswerMachineFactory,MOD_NAME);
@ -75,6 +75,7 @@ string AnswerMachineFactory::RecFileExt;
string AnswerMachineFactory::AnnouncePath;
string AnswerMachineFactory::DefaultAnnounce;
int AnswerMachineFactory::MaxRecordTime;
int AnswerMachineFactory::MinRecordTime = 0;
AmDynInvokeFactory* AnswerMachineFactory::UserTimer=0;
#ifdef USE_MYSQL
@ -383,6 +384,7 @@ int AnswerMachineFactory::onLoad()
#endif
MaxRecordTime = cfg.getParameterInt("max_record_time",DEFAULT_RECORD_TIME);
MinRecordTime = cfg.getParameterInt("min_record_time",DEFAULT_MIN_RECORD_TIME);
RecFileExt = cfg.getParameter("rec_file_ext",DEFAULT_AUDIO_EXT);
UserTimer = AmPlugIn::instance()->getFactory4Di("user_timer");
@ -635,10 +637,11 @@ void AnswerMachineDialog::onBye(const AmSipRequest& req)
void AnswerMachineDialog::sendMailNotification()
{
unsigned int rec_size = a_msg.getDataSize();
DBG("recorded data size: %i\n",rec_size);
if(!rec_size){
int rec_length = a_msg.getLength();
DBG("recorded file length: %i ms\n",rec_length);
if(rec_length <= AnswerMachineFactory::MinRecordTime){
DBG("recorded file too small. Not sending voicemail.\n");
unlink(msg_filename.c_str());
}
else {

@ -62,6 +62,7 @@ public:
static string AnnouncePath;
static string DefaultAnnounce;
static int MaxRecordTime;
static int MinRecordTime;
static AmDynInvokeFactory* UserTimer;
#ifdef USE_MYSQL

@ -1,24 +1,21 @@
# These are needed if you keep audio and template files in file system:
# if set, this overrides the email address, meaning that
# the voicemail will always be sent to that address.
# email_address = blub@mail.domain.net
#
#CFGOPTION_SEMS_ANNOUNCEPATH
# These are needed if you keep audio and template files in file system:
#
# path from which announcements are played:
announce_path=/usr/local/lib/sems/audio/voicemail/
#ENDCFGOPTION
#CFGOPTION_SEMS_ANNOUNCEMENT
#
# announcement played if no user/domain specific prompt found
default_announce=default_en.wav
#ENDCFGOPTION
#CFGOPTION_SEMS_TEMPLATEDIR
#
# path for email templates:
email_template_path=/usr/local/etc/sems/
#ENDCFGOPTION
# These are needed if you keep audio and template files in MySQL database:
#mysql_host=localhost
#mysql_user=sems
#mysql_passwd=sems
@ -26,9 +23,20 @@ email_template_path=/usr/local/etc/sems/
# These are independent on where audio and template files are kept:
#CFGOPTION_SEMS_RECORDTIME
#
# maximum voicemail message length, in seconds.
# After the maximum time, the call is ended by SEMS.
#
max_record_time=30
#ENDCFGOPTION
#
# optional: minimum voicemail message length, in milliseconds
# no voicemail is sent if the recorded message is shorter than
# or equal to the value set here.
# example - do not send voicemail shorter than 1.5s:
# min_record_time=1500
# default: 0
#min_record_time=0
# rec_file_ext : extension to recorded file, determines file
# format (wav, mp3; need mp3 plugin loaded for mp3)

@ -735,6 +735,16 @@ int AmAudioFile::write(unsigned int user_ts, unsigned int size)
return (!ferror(fp) ? s : -1);
}
int AmAudioFile::getLength()
{
if (!data_size || !fmt.get())
return 0;
return
fmt->bytes2samples(data_size) /
(fmt->rate/1000);
}
AmAudioFileFormat* AmAudioFile::fileName2Fmt(const string& name)
{
string ext = file_extension(name);

@ -415,6 +415,9 @@ public:
/** Gets data size in the current file */
int getDataSize() { return data_size; }
/** Gets length of the current file in ms */
int getLength();
/**
* @return MIME type corresponding to the audio file.
*/

Loading…
Cancel
Save