]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Merged revisions 254277 via svnmerge from
authorJeff Peeler <jpeeler@digium.com>
Wed, 24 Mar 2010 17:17:14 +0000 (17:17 +0000)
committerJeff Peeler <jpeeler@digium.com>
Wed, 24 Mar 2010 17:17:14 +0000 (17:17 +0000)
https://origsvn.digium.com/svn/asterisk/trunk

................
  r254277 | jpeeler | 2010-03-24 12:15:05 -0500 (Wed, 24 Mar 2010) | 78 lines

  Merged revisions 254235 via svnmerge from
  https://origsvn.digium.com/svn/asterisk/branches/1.4

  ........
    r254235 | jpeeler | 2010-03-23 19:37:23 -0500 (Tue, 23 Mar 2010) | 72 lines

    Ensure that monitor recordings are written to the correct location (again)

    This is an extension to 248860. As such the dialplan test has been extended:

    ; non absolute path, not combined
    exten => 5040, 1, monitor(wav,tmp/jeff/monitor_test)
    exten => 5040, n, dial(sip/5001)
    ; absolute path, not combined
    exten => 5041, 1, monitor(wav,/tmp/jeff/monitor_test2)
    exten => 5041, n, dial(sip/5001)
    ; no path, not combined
    exten => 5042, 1, monitor(wav,monitor_test3)
    exten => 5042, n, dial(sip/5001)
    ; combined: changemonitor from non absolute to no path (leaves tmp/jeff)
    exten => 5043, 1, monitor(wav,tmp/jeff/monitor_test4,m)
    exten => 5043, n, changemonitor(monitor_test5)
    exten => 5043, n, dial(sip/5001)
    ; combined: changemonitor from no path to non absolute path
    exten => 5044, 1, monitor(wav,monitor_test6,m)
    exten => 5044, n, changemonitor(tmp/jeff/monitor_test7) ; this wasn't possible before
    exten => 5044, n, dial(sip/5001)
    ; non absolute path, combined
    exten => 5045, 1, monitor(wav,tmp/jeff/monitor_test8,m)
    exten => 5045, n, dial(sip/5001)
    ; absolute path, combined
    exten => 5046, 1, monitor(wav,/tmp/jeff/monitor_test9,m)
    exten => 5046, n, dial(sip/5001)
    ; no path, combined
    exten => 5047, 1, monitor(wav,monitor_test10,m)
    exten => 5047, n, dial(sip/5001)
    ; combined: changemonitor from non absolute to absolute (leaves tmp/jeff)
    exten => 5048, 1, monitor(wav,tmp/jeff/monitor_test11,m)
    exten => 5048, n, changemonitor(/tmp/jeff/monitor_test12)
    exten => 5048, n, dial(sip/5001)
    ; combined: changemonitor from absolute to non absolute (leaves /tmp/jeff)
    exten => 5049, 1, monitor(wav,/tmp/jeff/monitor_test13,m)
    exten => 5049, n, changemonitor(tmp/jeff/monitor_test14)
    exten => 5049, n, dial(sip/5001)
    ; combined: changemonitor from no path to absolute
    exten => 5050, 1, monitor(wav,monitor_test15,m)
    exten => 5050, n, changemonitor(/tmp/jeff/monitor_test16)
    exten => 5050, n, dial(sip/5001)
    ; combined: changemonitor from absolute to no path (leaves /tmp/jeff)
    exten => 5051, 1, monitor(wav,/tmp/jeff/monitor_test17,m)
    exten => 5051, n, changemonitor(monitor_test18)
    exten => 5051, n, dial(sip/5001)
    ; not combined: changemonitor from non absolute to no path (leaves tmp/jeff)
    exten => 5052, 1, monitor(wav,tmp/jeff/monitor_test19)
    exten => 5052, n, changemonitor(monitor_test20)
    exten => 5052, n, dial(sip/5001)
    ; not combined: changemonitor from no path to non absolute
    exten => 5053, 1, monitor(wav,monitor_test21)
    exten => 5053, n, changemonitor(tmp/jeff/monitor_test22)
    exten => 5053, n, dial(sip/5001)
    ; not combined: changemonitor from non absolute to absolute (leaves tmp/jeff)
    exten => 5054, 1, monitor(wav,tmp/jeff/monitor_test23)
    exten => 5054, n, changemonitor(/tmp/jeff/monitor_test24)
    exten => 5054, n, dial(sip/5001)
    ; not combined: changemonitor from absolute to non absolute (leaves /tmp/jeff)
    exten => 5055, 1, monitor(wav,/tmp/jeff/monitor_test24)
    exten => 5055, n, changemonitor(tmp/jeff/monitor_test25)
    exten => 5055, n, dial(sip/5001)
    ; not combined: changemonitor from no path to absolute
    exten => 5056, 1, monitor(wav,monitor_test26)
    exten => 5056, n, changemonitor(/tmp/jeff/monitor_test27)
    exten => 5056, n, dial(sip/5001)
    ; not combined: changemonitor from absolute to no path (leaves /tmp/jeff)
    exten => 5057, 1, monitor(wav,/tmp/jeff/monitor_test28)
    exten => 5057, n, changemonitor(monitor_test29)
    exten => 5057, n, dial(sip/5001)
  ........
................

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

res/res_monitor.c

index d5e76a6672c22e5e10fdefdffce29634b60ffdc2..56f7d8f3f2a612b52262edead120060628fce069 100644 (file)
@@ -167,13 +167,14 @@ int ast_monitor_start(    struct ast_channel *chan, const char *format_spec,
                if (!ast_strlen_zero(fname_base)) {
                        int directory = strchr(fname_base, '/') ? 1 : 0;
                        const char *absolute = *fname_base == '/' ? "" : ast_config_AST_MONITOR_DIR;
+                       const char *absolute_suffix = *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);
+                       snprintf(monitor->read_filename, FILENAME_MAX, "%s%s%s-in",
+                                               absolute, absolute_suffix, fname_base);
+                       snprintf(monitor->write_filename, FILENAME_MAX, "%s%s%s-out",
+                                               absolute, absolute_suffix, fname_base);
+                       snprintf(monitor->filename_base, FILENAME_MAX, "%s%s%s",
+                                               absolute, absolute_suffix, fname_base);
 
                        /* try creating the directory just in case it doesn't exist */
                        if (directory) {
@@ -329,11 +330,9 @@ int ast_monitor_stop(struct ast_channel *chan, int need_lock)
                        char tmp[1024];
                        char tmp2[1024];
                        const char *format = !strcasecmp(chan->monitor->format,"wav49") ? "WAV" : chan->monitor->format;
-                       char *name = chan->monitor->filename_base;
-                       int directory = strchr(name, '/') ? 1 : 0;
-                       const char *dir = directory ? "" : ast_config_AST_MONITOR_DIR;
+                       char *fname_base = chan->monitor->filename_base;
                        const char *execute, *execute_args;
-                       const char *absolute = *name == '/' ? "" : "/";
+                       /* at this point, fname_base really is the full path */
 
                        /* Set the execute application */
                        execute = pbx_builtin_getvar_helper(chan, "MONITOR_EXEC");
@@ -351,9 +350,10 @@ int ast_monitor_stop(struct ast_channel *chan, int need_lock)
                                execute_args = "";
                        }
                        
-                       snprintf(tmp, sizeof(tmp), "%s \"%s%s%s-in.%s\" \"%s%s%s-out.%s\" \"%s%s%s.%s\" %s &", execute, dir, absolute, name, format, dir, absolute, name, format, dir, absolute, name, format,execute_args);
+                       snprintf(tmp, sizeof(tmp), "%s \"%s-in.%s\" \"%s-out.%s\" \"%s.%s\" %s &",
+                               execute, fname_base, format, fname_base, format, fname_base, format,execute_args);
                        if (delfiles) {
-                               snprintf(tmp2,sizeof(tmp2), "( %s& rm -f \"%s%s%s-\"* ) &",tmp, dir, absolute, name); /* remove legs when done mixing */
+                               snprintf(tmp2,sizeof(tmp2), "( %s& rm -f \"%s-\"* ) &",tmp, fname_base); /* remove legs when done mixing */
                                ast_copy_string(tmp, tmp2, sizeof(tmp));
                        }
                        ast_debug(1,"monitor executing %s\n",tmp);
@@ -423,11 +423,18 @@ int ast_monitor_change_fname(struct ast_channel *chan, const char *fname_base, i
        if (chan->monitor) {
                int directory = strchr(fname_base, '/') ? 1 : 0;
                const char *absolute = *fname_base == '/' ? "" : ast_config_AST_MONITOR_DIR;
+               const char *absolute_suffix = *fname_base == '/' ? "" : "/";
                char tmpstring[sizeof(chan->monitor->filename_base)] = "";
                int i, fd[2] = { -1, -1 }, doexit = 0;
 
                /* before continuing, see if we're trying to rename the file to itself... */
-               snprintf(tmpstring, sizeof(tmpstring), "%s/%s", absolute, fname_base);
+               snprintf(tmpstring, sizeof(tmpstring), "%s%s%s", absolute, absolute_suffix, fname_base);
+
+               /* try creating the directory just in case it doesn't exist */
+               if (directory) {
+                       char *name = ast_strdupa(tmpstring);
+                       ast_mkdir(dirname(name), 0777);
+               }
 
                /*!\note We cannot just compare filenames, due to symlinks, relative
                 * paths, and other possible filesystem issues.  We could use
@@ -459,6 +466,7 @@ int ast_monitor_change_fname(struct ast_channel *chan, const char *fname_base, i
                        }
                }
                unlink(tmpstring);
+               /* if previous monitor file existed in a subdirectory, the directory will not be removed */
                unlink(chan->monitor->filename_base);
 
                if (doexit) {
@@ -466,12 +474,6 @@ int ast_monitor_change_fname(struct ast_channel *chan, const char *fname_base, i
                        return 0;
                }
 
-               /* try creating the directory just in case it doesn't exist */
-               if (directory) {
-                       char *name = ast_strdupa(fname_base);
-                       ast_mkdir(dirname(name), 0777);
-               }
-
                ast_copy_string(chan->monitor->filename_base, tmpstring, sizeof(chan->monitor->filename_base));
                chan->monitor->filename_changed = 1;
        } else {