]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Ensure that monitor recordings are written to the correct location.
authorJeff Peeler <jpeeler@digium.com>
Thu, 25 Feb 2010 18:06:54 +0000 (18:06 +0000)
committerJeff Peeler <jpeeler@digium.com>
Thu, 25 Feb 2010 18:06:54 +0000 (18:06 +0000)
Recordings should be placed in the monitor directory when a non-absolute path
is used.

Exact dialplan used for testing:
exten => 5040, 1, monitor(wav,tmp/jeff/monitor_test,b)
exten => 5040, n, dial(sip/5001)
exten => 5041, 1, monitor(wav,/tmp/jeff/monitor_test2,b)
exten => 5041, n, dial(sip/5001)
exten => 5042, 1, monitor(wav,monitor_test3,b)
exten => 5042, n, dial(sip/5001)

ABE-2101

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@248757 65c4cc65-6c06-0410-ace0-fbb531ad65f3

res/res_monitor.c

index 30aa8105a2254af22df0ce59acbd4bb081644b66..f5e0911f75df349154cf33e8e987e517829a1952 100644 (file)
@@ -157,20 +157,20 @@ int ast_monitor_start(    struct ast_channel *chan, const char *format_spec,
                /* Determine file names */
                if (!ast_strlen_zero(fname_base)) {
                        int directory = strchr(fname_base, '/') ? 1 : 0;
-                       const char *absolute = *fname_base == '/' ? "" : "/";
+                       const char *absolute = *fname_base == '/' ? "" : ast_config_AST_MONITOR_DIR;
                        /* try creating the directory just in case it doesn't exist */
                        if (directory) {
                                char *name = strdup(fname_base);
-                               snprintf(tmp, sizeof(tmp), "mkdir -p \"%s\"",dirname(name));
+                               snprintf(tmp, sizeof(tmp), "mkdir -p \"%s/%s\"", absolute, dirname(name));
                                free(name);
                                ast_safe_system(tmp);
                        }
-                       snprintf(monitor->read_filename, FILENAME_MAX, "%s%s%s-in",
-                                               directory ? "" : ast_config_AST_MONITOR_DIR, absolute, fname_base);
-                       snprintf(monitor->write_filename, FILENAME_MAX, "%s%s%s-out",
-                                               directory ? "" : ast_config_AST_MONITOR_DIR, absolute, fname_base);
-                       snprintf(monitor->filename_base, FILENAME_MAX, "%s%s%s",
-                                               directory ? "" : ast_config_AST_MONITOR_DIR, absolute, fname_base);
+                       snprintf(monitor->read_filename, FILENAME_MAX, "%s/%s-in",
+                                               absolute, fname_base);
+                       snprintf(monitor->write_filename, FILENAME_MAX, "%s/%s-out",
+                                               absolute, fname_base);
+                       snprintf(monitor->filename_base, FILENAME_MAX, "%s/%s",
+                                               absolute, fname_base);
                } else {
                        ast_mutex_lock(&monitorlock);
                        snprintf(monitor->read_filename, FILENAME_MAX, "%s/audio-in-%ld",