[asterisk-users] Voicemail volume patch
kjcsb
kjcsb at NOPSPM.orcon.net.nz
Thu Jul 20 23:47:57 MST 2006
There is a patch available for the quiet voicemail volume issue (bug 6237)
but it isn't intended to work with 1.2.9. The patch below will give you this
functionality for 1.2.9. Add the volgain= parameter to voicemail.conf and
make sure sox is installed.
--- apps/app_voicemail.c.backup 2006-07-18 08:52:14.000000000 +1200
+++ apps/app_voicemail.c 2006-07-21 08:18:42.000000000 +1200
@@ -229,6 +229,7 @@
unsigned int flags; /*!< VM_ flags */
int saydurationm;
int maxmsg; /*!< Maximum number of msgs per folder for this mailbox */
+ double volgain; /*!< Volume gain for voicemails sent via email */
struct ast_vm_user *next;
};
@@ -386,6 +387,7 @@
static char externnotify[160];
static char vmfmts[80];
+static double volgain;
static int vmminmessage;
static int vmmaxmessage;
static int maxgreet;
@@ -434,6 +436,7 @@
ast_copy_string(vmu->exit, exitcontext, sizeof(vmu->exit));
if (maxmsg)
vmu->maxmsg = maxmsg;
+ vmu->volgain = volgain;
}
static void apply_option(struct ast_vm_user *vmu, const char *var, const
char *value)
@@ -486,6 +489,8 @@
ast_log(LOG_WARNING, "Maximum number of messages per folder is %i.
Cannot accept value maxmsg=%s\n", MAXMSGLIMIT, value);
vmu->maxmsg = MAXMSGLIMIT;
}
+ } else if (!strcasecmp(var, "volgain")) {
+ sscanf(value, "%lf", &vmu->volgain);
} else if (!strcasecmp(var, "options")) {
apply_options(vmu, value);
}
@@ -1649,6 +1654,7 @@
char dur[256];
char tmp[80] = "/tmp/astmail-XXXXXX";
char tmp2[256];
+ char tmpcmd[256];
time_t t;
struct tm tm;
struct vm_zone *the_zone = NULL;
@@ -1774,10 +1780,21 @@
}
if (attach_user_voicemail) {
/* Eww. We want formats to tell us their own MIME type */
- char *ctype = "audio/x-";
- if (!strcasecmp(format, "ogg"))
- ctype = "application/";
-
+ char *ctype = (!strcasecmp(format, "ogg")) ? "application/" :
"audio/x-";
+
+ char tmpdir[256], newtmp[256];
+
+ create_dirpath(tmpdir, sizeof(tmpdir), vmu->context, vmu->mailbox,
"tmp");
+ snprintf(newtmp, sizeof(newtmp), "%s/XXXXXX", tmpdir);
+ mkstemp(newtmp);
+ ast_log(LOG_DEBUG, "newtmp: %s\n", newtmp);
+ if (vmu->volgain < -.001 || vmu->volgain > .001) {
+ snprintf(tmpcmd, sizeof(tmpcmd), "sox -v %.4f %s.%s %s.%s",
vmu->volgain, attach, format, newtmp, format);
+ ast_safe_system(tmpcmd);
+ attach = newtmp;
+ ast_log(LOG_DEBUG, "VOLGAIN: Stored at: %s.%s - Level: %.4f - Mailbox:
%s\n", attach, format, vmu->volgain, mailbox);
+ }
+
fprintf(p, "--%s\n", bound);
fprintf(p, "Content-Type: %s%s; name=\"msg%04d.%s\"\n", ctype, format,
msgnum, format);
fprintf(p, "Content-Transfer-Encoding: base64\n");
@@ -1787,6 +1804,7 @@
snprintf(fname, sizeof(fname), "%s.%s", attach, format);
base_encode(fname, p);
fprintf(p, "\n\n--%s--\n.\n", bound);
+ unlink(newtmp);
}
fclose(p);
snprintf(tmp2, sizeof(tmp2), "( %s < %s ; rm -f %s ) &", mailcmd, tmp,
tmp);
@@ -5883,6 +5901,7 @@
char *exitcxt = NULL;
char *extpc;
char *emaildateformatstr;
+ char *volgainstr;
int x;
int tmpadsi[4];
@@ -5919,6 +5938,10 @@
astsearch = "no";
ast_set2_flag((&globalflags), ast_true(astsearch), VM_SEARCH);
+ volgain = 0.0;
+ if ((volgainstr = ast_variable_retrieve(cfg, "general", "volgain")))
+ sscanf(volgainstr, "%lf", &volgain);
+
#ifdef USE_ODBC_STORAGE
strcpy(odbc_database, "asterisk");
if ((thresholdstr = ast_variable_retrieve(cfg, "general",
"odbcstorage"))) {
More information about the asterisk-users
mailing list