|
|
|
@ -174,6 +174,7 @@ int ast_monitor_stop( struct ast_channel *chan, int need_lock )
|
|
|
|
|
{
|
|
|
|
|
char *execute;
|
|
|
|
|
int soxmix =0;
|
|
|
|
|
|
|
|
|
|
if (need_lock) {
|
|
|
|
|
if (ast_mutex_lock(&chan->lock)) {
|
|
|
|
|
ast_log(LOG_WARNING, "Unable to lock channel\n");
|
|
|
|
@ -193,29 +194,23 @@ int ast_monitor_stop( struct ast_channel *chan, int need_lock )
|
|
|
|
|
|
|
|
|
|
if (chan->monitor->filename_changed&&strlen(chan->monitor->filename_base)) {
|
|
|
|
|
if (ast_fileexists(chan->monitor->read_filename,NULL,NULL) > 0 ) {
|
|
|
|
|
snprintf( filename, FILENAME_MAX, "%s-in",
|
|
|
|
|
chan->monitor->filename_base );
|
|
|
|
|
snprintf(filename, FILENAME_MAX, "%s-in", chan->monitor->filename_base);
|
|
|
|
|
if (ast_fileexists( filename, NULL, NULL ) > 0) {
|
|
|
|
|
ast_filedelete( filename, NULL );
|
|
|
|
|
}
|
|
|
|
|
ast_filerename( chan->monitor->read_filename, filename,
|
|
|
|
|
chan->monitor->format );
|
|
|
|
|
ast_filerename(chan->monitor->read_filename, filename, chan->monitor->format );
|
|
|
|
|
} else {
|
|
|
|
|
ast_log( LOG_WARNING, "File %s not found\n",
|
|
|
|
|
chan->monitor->read_filename );
|
|
|
|
|
ast_log(LOG_WARNING, "File %s not found\n", chan->monitor->read_filename );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ast_fileexists(chan->monitor->write_filename,NULL,NULL) > 0) {
|
|
|
|
|
snprintf( filename, FILENAME_MAX, "%s-out",
|
|
|
|
|
chan->monitor->filename_base );
|
|
|
|
|
snprintf(filename, FILENAME_MAX, "%s-out", chan->monitor->filename_base );
|
|
|
|
|
if (ast_fileexists(filename, NULL, NULL) > 0 ) {
|
|
|
|
|
ast_filedelete(filename, NULL);
|
|
|
|
|
}
|
|
|
|
|
ast_filerename( chan->monitor->write_filename, filename,
|
|
|
|
|
chan->monitor->format );
|
|
|
|
|
ast_filerename(chan->monitor->write_filename, filename, chan->monitor->format );
|
|
|
|
|
} else {
|
|
|
|
|
ast_log( LOG_WARNING, "File %s not found\n",
|
|
|
|
|
chan->monitor->write_filename );
|
|
|
|
|
ast_log(LOG_WARNING, "File %s not found\n", chan->monitor->write_filename );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -248,21 +243,17 @@ int ast_monitor_stop( struct ast_channel *chan, int need_lock )
|
|
|
|
|
chan->monitor = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( need_lock ) {
|
|
|
|
|
if (need_lock)
|
|
|
|
|
ast_mutex_unlock(&chan->lock);
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Change monitoring filename of a channel */
|
|
|
|
|
int ast_monitor_change_fname( struct ast_channel *chan,
|
|
|
|
|
const char *fname_base, int need_lock )
|
|
|
|
|
int ast_monitor_change_fname(struct ast_channel *chan, const char *fname_base, int need_lock)
|
|
|
|
|
{
|
|
|
|
|
char tmp[256];
|
|
|
|
|
if ((!fname_base) || (!strlen(fname_base))) {
|
|
|
|
|
ast_log( LOG_WARNING,
|
|
|
|
|
"Cannot change monitor filename of channel %s to null",
|
|
|
|
|
chan->name );
|
|
|
|
|
ast_log(LOG_WARNING, "Cannot change monitor filename of channel %s to null", chan->name );
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -283,18 +274,14 @@ int ast_monitor_change_fname( struct ast_channel *chan,
|
|
|
|
|
system(tmp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
snprintf( chan->monitor->filename_base, FILENAME_MAX, "%s/%s",
|
|
|
|
|
directory ? "" : AST_MONITOR_DIR, fname_base );
|
|
|
|
|
snprintf(chan->monitor->filename_base, FILENAME_MAX, "%s/%s", directory ? "" : AST_MONITOR_DIR, fname_base );
|
|
|
|
|
} else {
|
|
|
|
|
ast_log( LOG_WARNING,
|
|
|
|
|
"Cannot change monitor filename of channel %s to %s, monitoring not started",
|
|
|
|
|
chan->name, fname_base );
|
|
|
|
|
|
|
|
|
|
ast_log(LOG_WARNING, "Cannot change monitor filename of channel %s to %s, monitoring not started", chan->name, fname_base );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( need_lock ) {
|
|
|
|
|
if (need_lock)
|
|
|
|
|
ast_mutex_unlock(&chan->lock);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -326,14 +313,12 @@ static int start_monitor_exec(struct ast_channel *chan, void *data)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
res = ast_monitor_start(chan, format, fname_base, 1);
|
|
|
|
|
if( res < 0 ) {
|
|
|
|
|
if (res < 0)
|
|
|
|
|
res = ast_monitor_change_fname( chan, fname_base, 1 );
|
|
|
|
|
}
|
|
|
|
|
ast_monitor_setjoinfiles(chan, joinfiles);
|
|
|
|
|
|
|
|
|
|
if( arg ) {
|
|
|
|
|
if (arg)
|
|
|
|
|
free( arg );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|