Here I found this patch on the www.

Included in this patch:

   * “From User” functionality
         o This function allows us to send voicemail FROM the user that
           left the message, so you can just click reply when you
           receive the email
   * “MP3 Conversion”
         o This function converts the voicemail to mp3 format before
           emailing it to the user, providing more application
           saturation and not requiring special codecs in most cases.
   * “Volume Gain”
         o This increases (or decreases) the volume of messages that
           are emailed.
   * “Forward Compatibility”
         o I call this compatibility since it makes forwarding the
           message act the same as regular voicemail messages do. The
           original handling was that it would be dropped in a user’s
           inbox and the forward function does all the work. I didn’t
           write the patch, but we do have it in place and working and
           I didn’t realy think it was necessary to remove it from the
           patch file.

The only patch that actually requires any sort of database backend modification is the From User patch. We use an email lookup table (named emaillookup… you can name it anything in the database, but it must be called emaillookup in extconfig) that contains all of our user’s phone numbers, cid names, extension, and email addresses:

Table "public.emaillookup"

 Column  |         Type          | Modifiers
----------+-----------------------+-----------
cidnum   | character varying(10) |
email    | character varying(60) |
cidname  | character varying(60) |
username | character varying(15) |
exten    | character varying(5)  |

And in extconfig.conf:

[settings]
emaillookup => odbc,ast_cnf,emaillookup ; use your standard db connection here



Remzi Semsettin Turer wrote:
Why not use compressed WAV, in other words WAV49, Mixmonitor and Voicemails 
support it. That's what we use and supported by many devices, included 
Blackberry. (haven't checked MP3).

Cheers,

Remzi


-----Original Message-----
From: Reza - Asterisk Enthusiast [mailto:[EMAIL PROTECTED]
Sent: Thursday, December 20, 2007 12:18 AM
To: TAUG
Subject: [on-asterisk] MP3 Voice Mail and Call recording with MixMonitor

Two Quick question:

MixMonitor natively records files in gsm.   Does anyone know whether built
in MP3 recording is supported in asterisk 1.4?     I want to stay away from
3rd party apps invoked by system() or any form of soxmix.

Also our clients are insisting voicemails be sent in MP3 format via email
attachments.  Any suggestions and/or directions on how we can accomplish
this?

Thanks!
Reza.



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Index: apps/app_voicemail.c
===================================================================
--- apps/app_voicemail.c        (revision 39569)
+++ apps/app_voicemail.c        (working copy)
@@ -113,6 +113,8 @@
 #define VM_DELETE              (1 << 12)
 #define VM_ALLOCED             (1 << 13)
 #define VM_SEARCH              (1 << 14)
+#define VM_FROMUSER            (1 << 15)       /* Set voicemail email to come 
from caller */
+#define VM_CONVERTMP3          (1 << 16)       /* Convert mailed wav to mp3 */
 
 #define ERROR_LOCK_PATH                -100
 
@@ -386,6 +388,8 @@
 static char externnotify[160]; 
 
 static char vmfmts[80];
+static char archive[256];
+static int volgain;
 static int vmminmessage;
 static int vmmaxmessage;
 static int maxgreet;
@@ -1651,9 +1655,12 @@
        char dur[256];
        char tmp[80] = "/tmp/astmail-XXXXXX";
        char tmp2[256];
+       char newtmp[256];
+       char tmpcmd[256];
        time_t t;
        struct tm tm;
        struct vm_zone *the_zone = NULL;
+       ast_log(LOG_DEBUG, "FROMUSER: srcemail: %s - cidname: %s\n", srcemail, 
cidname);
        if (vmu && ast_strlen_zero(vmu->email)) {
                ast_log(LOG_WARNING, "E-mail address missing for mailbox [%s].  
E-mail will not be sent.\n", vmu->mailbox);
                return(0);
@@ -1705,7 +1712,9 @@
                /* Set date format for voicemail mail */
                strftime(date, sizeof(date), emaildateformat, &tm);
 
-               if (*fromstring) {
+               if (!ast_strlen_zero(cidname) && ast_test_flag((&globalflags), 
VM_FROMUSER)) {
+                       fprintf(p, "From: \"%s\" <%s>\n",cidname,who);
+               } else if (*fromstring) {
                        struct ast_channel *ast = ast_channel_alloc(0);
                        if (ast) {
                                char *passdata;
@@ -1714,13 +1723,13 @@
                                        memset(passdata, 0, vmlen);
                                        prep_email_sub_vars(ast,vmu,msgnum + 
1,context,mailbox,cidnum, cidname,dur,date,passdata, vmlen);
                                        
pbx_substitute_variables_helper(ast,fromstring,passdata,vmlen);
-                                       fprintf(p, "From: %s 
<%s>\n",passdata,who);
+                                       fprintf(p, "From: \"%s\" 
<%s>\n",passdata,who);
                                } else ast_log(LOG_WARNING, "Cannot allocate 
workspace for variable substitution\n");
                                ast_channel_free(ast);
                        } else ast_log(LOG_WARNING, "Cannot allocate the 
channel for variables substitution\n");
                } else
                        fprintf(p, "From: Asterisk PBX <%s>\n", who);
-               fprintf(p, "To: %s <%s>\n", vmu->fullname, vmu->email);
+               fprintf(p, "To: \"%s\" <%s>\n", vmu->fullname, vmu->email);
 
                if (emailsubject) {
                        struct ast_channel *ast = ast_channel_alloc(0);
@@ -1779,16 +1788,36 @@
                        char *ctype = "audio/x-";
                        if (!strcasecmp(format, "ogg"))
                                ctype = "application/";
-               
+                       char *ctypeformat = format;
+                       snprintf(newtmp, sizeof(newtmp), "%s/%s-XXXXXX", 
archive, mailbox);
+                       mkstemp(newtmp);
+                       ast_log(LOG_DEBUG, "newtmp: %s\n", newtmp);
+                       if (volgain) {
+                               snprintf(tmpcmd, sizeof(tmpcmd), "sox -v %d 
%s.%s %s.%s", volgain, attach, format, newtmp, format);
+                               ast_safe_system(tmpcmd);
+                               attach = newtmp;
+                               ast_log(LOG_DEBUG, "VOLGAIN: Stored at: %s.%s - 
Level: %d - Mailbox: %s\n", attach, format, volgain, mailbox);
+                       }               
+                       if (ast_test_flag((&globalflags), VM_CONVERTMP3)) {
+                               snprintf(tmpcmd, sizeof(tmpcmd), "lame -h 
--resample 48 %s.%s %s.mp3", attach, format, newtmp);
+                               ast_safe_system(tmpcmd);
+                               ast_log(LOG_DEBUG, "CONVERTMP3: Stored at: 
%s.mp3 Converted: %s\n", newtmp, format);
+                               attach = newtmp;
+                               ctype = "audio/";
+                               ctypeformat = "mpeg";
+                               format = "mp3";
+                       }
                        fprintf(p, "--%s\n", bound);
-                       fprintf(p, "Content-Type: %s%s; name=\"msg%04d.%s\"\n", 
ctype, format, msgnum, format);
+                       fprintf(p, "Content-Type: %s%s; name=\"msg%04d.%s\"\n", 
ctype, ctypeformat, msgnum, format);
                        fprintf(p, "Content-Transfer-Encoding: base64\n");
                        fprintf(p, "Content-Description: Voicemail sound 
attachment.\n");
                        fprintf(p, "Content-Disposition: attachment; 
filename=\"msg%04d.%s\"\n\n", msgnum, format);
+                       snprintf(fname, sizeof(fname), "%s.%s", attach, format);
 
-                       snprintf(fname, sizeof(fname), "%s.%s", attach, format);
                        base_encode(fname, p);
                        fprintf(p, "\n\n--%s--\n.\n", bound);
+                       snprintf(tmpcmd, sizeof(tmpcmd), "rm -f %s", newtmp);
+                       ast_safe_system(tmpcmd);
                }
                fclose(p);
                snprintf(tmp2, sizeof(tmp2), "( %s < %s ; rm -f %s ) &", 
mailcmd, tmp, tmp);
@@ -3330,6 +3359,7 @@
 {
        char todir[256], fn[256], ext_context[256], *stringp;
        int newmsgs = 0, oldmsgs = 0;
+       struct ast_variable *var, *tmp;
 
        make_dir(todir, sizeof(todir), vmu->context, vmu->mailbox, "INBOX");
        make_file(fn, sizeof(fn), todir, msgnum);
@@ -3347,6 +3377,44 @@
                        attach_user_voicemail = ast_test_flag(vmu, VM_ATTACH);
                        if (!ast_strlen_zero(vmu->serveremail))
                                myserveremail = vmu->serveremail;
+                       if (ast_test_flag((&globalflags), VM_FROMUSER)) {
+                               var = ast_load_realtime("voicemail", "mailbox", 
cidnum, NULL);
+                               if (var) {
+                                       tmp = var;
+                                       while(tmp) {
+                                               printf("%s => %s\n", tmp->name, 
tmp->value);
+                                               if (!strcasecmp(tmp->name, 
"email")) {
+                                                       if 
(!ast_strlen_zero(tmp->value))
+                                                               myserveremail = 
tmp->value;
+                                               } else if 
(!strcasecmp(tmp->name, "fullname")) {
+                                                       if 
(!ast_strlen_zero(tmp->value))
+                                                               cidname = 
tmp->value;
+                                               }
+                                               tmp = tmp->next;
+                                       }
+                               } else {
+                                       var = ast_load_realtime("emaillookup", 
"cidnum", cidnum, NULL);
+                                       if (!var) {
+                                               var = 
ast_load_realtime("emaillookup", "exten", cidnum, NULL);
+                                               if (var) {
+                                                       tmp = var;
+                                                       while(tmp) {
+                                                               printf("%s => 
%s\n", tmp->name, tmp->value);
+                                                               if 
(!strcasecmp(tmp->name, "email")) {
+                                                                       if 
(!ast_strlen_zero(tmp->value)) {
+                                                                               
myserveremail = tmp->value;
+                                                               
ast_verbose(VERBOSE_PREFIX_3 "Sending email from user: '%s' at email address 
'%s'\n", cidnum, myserveremail);
+                                                                       }
+                                                               } else if 
(!strcasecmp(tmp->name, "cidname")) {
+                                                                       if 
(!ast_strlen_zero(tmp->value))
+                                                                               
cidname = tmp->value;
+                                                               }
+                                                               tmp = tmp->next;
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
                        sendmail(myserveremail, vmu, msgnum, vmu->context, 
vmu->mailbox, cidnum, cidname, fn, fmt, duration, attach_user_voicemail);
                }
 
@@ -3377,18 +3445,8 @@
                           char *fmt, int flag, signed char record_gain)
 {
        char username[70]="";
-       char sys[256];
-       char todir[256];
-       int todircount=0;
-       int duration;
-       struct ast_config *mif;
-       char miffile[256];
-       char fn[256];
-       char callerid[512];
-       char ext_context[256]="";
        int res = 0, cmd = 0;
        struct ast_vm_user *receiver = NULL, *extensions = NULL, *vmtmp = NULL, 
*vmfree;
-       char tmp[256];
        char *stringp, *s;
        int saved_messages = 0, found = 0;
        int valid_extensions = 0;
@@ -3521,75 +3579,8 @@
                cmd = vm_forwardoptions(chan, sender, dir, curmsg, vmfmts, 
context, record_gain);
                if (!cmd) {
                        while (!res && vmtmp) {
-                               /* if (ast_play_and_wait(chan, "vm-savedto"))
-                                       break;
-                               */
-                               snprintf(todir, sizeof(todir), "%s%s/%s/INBOX", 
 VM_SPOOL_DIR, vmtmp->context, vmtmp->mailbox);
-                               snprintf(sys, sizeof(sys), "mkdir -p %s\n", 
todir);
-                               snprintf(ext_context, sizeof(ext_context), 
"[EMAIL PROTECTED]", vmtmp->mailbox, vmtmp->context);
-                               ast_log(LOG_DEBUG, "%s", sys);
-                               ast_safe_system(sys);
-               
-                               res = count_messages(receiver, todir);
-
-                               if ( (res == ERROR_LOCK_PATH) || (res < 0) ) {
-                                       if (res == ERROR_LOCK_PATH)
-                                               ast_log(LOG_WARNING, "Unable to 
lock the directory %s to forward the requested vmail msg!\n", todir);
-                                       else
-                                               ast_log(LOG_WARNING, "Unable to 
determine how many msgs are in the destination folder!\n");
-                                       break;
-                               }
-                               todircount = res;
-                               ast_copy_string(tmp, fmt, sizeof(tmp));
-                               stringp = tmp;
-                               while ((s = strsep(&stringp, "|"))) {
-                                       /* XXX This is a hack -- we should use 
build_filename or similar XXX */
-                                       if (!strcasecmp(s, "wav49"))
-                                               s = "WAV";
-                                       snprintf(sys, sizeof(sys), "cp 
%s/msg%04d.%s %s/msg%04d.%s\n", dir, curmsg, s, todir, todircount, s);
-                                       ast_log(LOG_DEBUG, "%s", sys);
-                                       ast_safe_system(sys);
-                               }
-                               snprintf(sys, sizeof(sys), "cp %s/msg%04d.txt 
%s/msg%04d.txt\n", dir, curmsg, todir, todircount);
-                               ast_log(LOG_DEBUG, "%s", sys);
-                               ast_safe_system(sys);
-                               snprintf(fn, sizeof(fn), "%s/msg%04d", 
todir,todircount);
-
-                               STORE(todir, vmtmp->mailbox, vmtmp->context, 
todircount);
+                               copy_message(chan, sender, 0, curmsg, 0, vmtmp, 
fmt);
        
-                               /* load the information on the source message 
so we can send an e-mail like a new message */
-                               snprintf(miffile, sizeof(miffile), 
"%s/msg%04d.txt", dir, curmsg);
-                               if ((mif=ast_config_load(miffile))) {
-       
-                                       /* set callerid and duration variables 
*/
-                                       snprintf(callerid, sizeof(callerid), 
"FWD from: %s from %s", sender->fullname, ast_variable_retrieve(mif, NULL, 
"callerid"));
-                                       s = ast_variable_retrieve(mif, NULL, 
"duration");
-                                       if (s)
-                                               duration = atoi(s);
-                                       else
-                                               duration = 0;
-                                       if (!ast_strlen_zero(vmtmp->email)) {
-                                               int attach_user_voicemail = 
ast_test_flag((&globalflags), VM_ATTACH);
-                                               char *myserveremail = 
serveremail;
-                                               attach_user_voicemail = 
ast_test_flag(vmtmp, VM_ATTACH);
-                                               if 
(!ast_strlen_zero(vmtmp->serveremail))
-                                                       myserveremail = 
vmtmp->serveremail;
-                                               sendmail(myserveremail, vmtmp, 
todircount, vmtmp->context, vmtmp->mailbox, chan->cid.cid_num, 
chan->cid.cid_name, fn, tmp, duration, attach_user_voicemail);
-                                       }
-
-                                       if (!ast_strlen_zero(vmtmp->pager)) {
-                                               char *myserveremail = 
serveremail;
-                                               if 
(!ast_strlen_zero(vmtmp->serveremail))
-                                                       myserveremail = 
vmtmp->serveremail;
-                                               sendpage(myserveremail, 
vmtmp->pager, todircount, vmtmp->context, vmtmp->mailbox, chan->cid.cid_num, 
chan->cid.cid_name, duration, vmtmp);
-                                       }
-                                 
-                                       ast_config_destroy(mif); /* or here */
-                               }
-                               /* Leave voicemail for someone */
-                               manager_event(EVENT_FLAG_CALL, 
"MessageWaiting", "Mailbox: %s\r\nWaiting: %d\r\n", ext_context, 
has_voicemail(ext_context, NULL));
-                               run_externnotify(vmtmp->context, 
vmtmp->mailbox);
-       
                                saved_messages++;
                                vmfree = vmtmp;
                                vmtmp = vmtmp->next;
@@ -5897,6 +5888,10 @@
        char *exitcxt = NULL;   
        char *extpc;
        char *emaildateformatstr;
+       char *volgainstr;
+       char *archivestr;
+       char *fromuserstr;
+       char *convertmp3str;
        int x;
        int tmpadsi[4];
 
@@ -5933,6 +5928,26 @@
                        astsearch = "no";
                ast_set2_flag((&globalflags), ast_true(astsearch), VM_SEARCH);
 
+               if (!(fromuserstr = ast_variable_retrieve(cfg, "general", 
"fromuser")))
+                       fromuserstr = "no";
+               ast_set2_flag((&globalflags), ast_true(fromuserstr), 
VM_FROMUSER);
+
+               if (!(convertmp3str = ast_variable_retrieve(cfg, "general", 
"convertmp3")))
+                       convertmp3str = "no";
+               ast_set2_flag((&globalflags), ast_true(convertmp3str), 
VM_CONVERTMP3);
+
+               if (!(volgainstr = ast_variable_retrieve(cfg, "general", 
"volgain"))) {
+                       volgain = 0;
+               } else {
+                       volgain = atoi(volgainstr);
+               }
+
+               if (!(archivestr = ast_variable_retrieve(cfg, "general", 
"archivedir"))) {
+                       snprintf(archive, sizeof(archive), "/tmp");
+               } else {
+                       strcpy(archive, archivestr);
+               }
+
 #ifdef USE_ODBC_STORAGE
                strcpy(odbc_database, "asterisk");
                if ((thresholdstr = ast_variable_retrieve(cfg, "general", 
"odbcstorage"))) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to