--- res_monitor.c 2004-03-04 16:03:31.000000000 -0600 +++ res_monitor.c 2004-04-07 01:08:21.000000000 -0500 @@ -31,7 +31,9 @@ " file_format -- optional, if not set, defaults to \"wav\"\n" " fname_base -- if set, changes the filename used to the one specified.\n" " options:\n" - " 'm' - when the recording ends mix the two leg files into one using 'soxmix' utility which has to be installed on the system.\n"; + " 'm' - when the recording ends mix the two leg files into one using 'soxmix' utility which has to be installed on the system.\n" + " 'c' - when the recording ends, call an external customizable script to handle what to do with the files. \n" + " NOTE: this option calls a script named callmerge.sh, and exports the path, filename, and format (extension), in that order, to the script."; static char *stopmonitor_synopsis = "Stop monitoring a channel"; @@ -216,6 +218,20 @@ if (system(tmp) == -1) ast_log(LOG_WARNING, "You might not have the soxmix installed and available in the path, please check.\n"); } + if (chan->monitor->customjoin && strlen(chan->monitor->filename_base)) { + char tmp[1024]; + char *format = !strcasecmp(chan->monitor->format,"wav49") ? "WAV" : chan->monitor->format; + char *name = chan->monitor->filename_base; + int directory = strchr(name, '/') ? 1 : 0; + char *dir = directory ? "" : AST_MONITOR_DIR; + snprintf(tmp, sizeof(tmp), "nice -n 19 callmerge.sh %s %s %s &", dir, name, format); + if 0 + ast_verbose("executing custom monitor merge script %s\n",tmp); + endif + if (system(tmp) == -1) + ast_log(LOG_WARNING, "You specified an external merge script, but either it doesn't\n exist, or there is a problem.\n"); + } + free( chan->monitor->format ); free( chan->monitor ); chan->monitor = NULL; @@ -278,6 +294,7 @@ char *fname_base = NULL; char *options = NULL; int joinfiles = 0; + int customjoin = 0; int res; /* Parse arguments. */ @@ -293,6 +310,8 @@ options++; if (strchr(options, 'm')) joinfiles = 1; + if (strchr(optinos, 'c')) + customjoin =1; } } @@ -303,7 +322,8 @@ res = ast_monitor_change_fname( chan, fname_base, 1 ); } ast_monitor_setjoinfiles(chan, joinfiles); - + ast_monitor_setcustomjoin(chan, customjoin); + + ast_verbose("executing custom monitor merge script %s\n",tmp); + endif + if (system(tmp) == -1) + ast_log(LOG_WARNING, "You specified an external merge script, but either it doesn't\n exist, or there is a problem.\n"); + } + free( chan->monitor->format ); free( chan->monitor ); chan->monitor = NULL; @@ -278,6 +294,7 @@ char *fname_base = NULL; char *options = NULL; int joinfiles = 0; + int customjoin = 0; int res; /* Parse arguments. */ @@ -293,6 +310,8 @@ options++; if (strchr(options, 'm')) joinfiles = 1; + if (strchr(optinos, 'c')) + customjoin =1; } } @@ -303,7 +322,8 @@ res = ast_monitor_change_fname( chan, fname_base, 1 ); } ast_monitor_setjoinfiles(chan, joinfiles); - + ast_monitor_setcustomjoin(chan, customjoin); + if( arg ) { free( arg ); } @@ -429,6 +449,12 @@ chan->monitor->joinfiles = turnon; } +void ast_monitor_setcustomjoin(struct ast_channel *chan, int turnon) +{ + if (chan->monitor) + chan->monitor->customjoin = turnon; +} + int load_module(void) { ast_register_application( "Monitor", start_monitor_exec, monitor_synopsis, monitor_descrip );