--- ../../asterisk/res/res_monitor.c 2004-02-05 22:52:03.000000000 -0700 +++ res/res_monitor.c 2004-04-07 00:38:26.072488157 -0600 @@ -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 1 + 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,14 @@ options++; if (strchr(options, 'm')) joinfiles = 1; + if (strchr(options, 'c')) + customjoin =1; + + if (joinfiles && customjoin) { + ast_log(LOG_WARNING, "Can't use both 'm' and 'c'! Turning off custom scripting!"); + customjoin = 0; + } + } } @@ -303,7 +328,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 +455,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 );